source: trunk/Sparkle/SUPlainInstaller.m @ 1046

Revision 1029, 2.4 KB checked in by speck, 9 months ago (diff)

Add support for using only IPv4 (suppressing all IPv6) by creating the file /Library/GlimmerBlocker?/preferIPv4Stack.txt
Fix bug in Sparkle (missing import) and suppress warning of calls of deprecated functions.

Line 
1//
2//  SUPlainInstaller.m
3//  Sparkle
4//
5//  Created by Andy Matuschak on 4/10/08.
6//  Copyright 2008 Andy Matuschak. All rights reserved.
7//
8
9#import "SUPlainInstaller.h"
10#import "SUPlainInstallerInternals.h"
11#import "SUHost.h"
12
13NSString *SUInstallerPathKey = @"SUInstallerPath";
14NSString *SUInstallerHostKey = @"SUInstallerHost";
15NSString *SUInstallerDelegateKey = @"SUInstallerDelegate";
16NSString *SUInstallerVersionComparatorKey = @"SUInstallerVersionComparator";
17
18@implementation SUPlainInstaller
19
20+ (void)installPath:(NSString *)path overHost:(SUHost *)bundle delegate:delegate versionComparator:(id <SUVersionComparison>)comparator
21{
22    NSError *error;
23    BOOL result = YES;
24
25    // Prevent malicious downgrades:
26    if ([comparator compareVersion:[bundle version] toVersion:[[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]] == NSOrderedDescending)
27    {
28        NSString * errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Possible attack in progress! Attempting to \"upgrade\" from %@ to %@. Aborting update.", [bundle version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]];
29        result = NO;
30        error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
31    }
32   
33    if (result)
34        result = [self copyPathWithAuthentication:path overPath:[bundle bundlePath] error:&error];
35    [self _finishInstallationWithResult:result host:bundle error:error delegate:delegate];
36}
37
38+ (void)_performInstallationWithInfo:(NSDictionary *)info
39{
40    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
41   
42    [self installPath:[info objectForKey:SUInstallerPathKey] overHost:[info objectForKey:SUInstallerHostKey] delegate:[info objectForKey:SUInstallerDelegateKey] versionComparator:[info objectForKey:SUInstallerVersionComparatorKey]];
43   
44    [pool drain];
45}
46
47+ (void)performInstallationWithPath:(NSString *)path host:(SUHost *)host delegate:delegate synchronously:(BOOL)synchronously versionComparator:(id <SUVersionComparison>)comparator
48{
49    NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:path, SUInstallerPathKey, host, SUInstallerHostKey, delegate, SUInstallerDelegateKey, comparator, SUInstallerVersionComparatorKey, nil];
50    if (synchronously)
51        [self _performInstallationWithInfo:info];
52    else
53        [NSThread detachNewThreadSelector:@selector(_performInstallationWithInfo:) toTarget:self withObject:info];
54}
55
56@end
Note: See TracBrowser for help on using the repository browser.