From b010f1aaf0a8b6b45f67f66c8d347f3804559a68 Mon Sep 17 00:00:00 2001 From: andym Date: Fri, 4 Apr 2008 16:00:50 +0000 Subject: [PATCH] Removed extraneous source file I forgot about. Fixed a stupid error in the last build which prevented Sparkle from actually, you know, working. Also, revision 144 is a patch courtesy Cedric Luthi; many thanks to him for a great contribution. --- NSFileManager+Authentication.m | 7 +--- SUUpdater+Authentication.m | 58 ---------------------------------- 2 files changed, 1 insertion(+), 64 deletions(-) delete mode 100644 SUUpdater+Authentication.m diff --git a/NSFileManager+Authentication.m b/NSFileManager+Authentication.m index 60e873f0..07876427 100644 --- a/NSFileManager+Authentication.m +++ b/NSFileManager+Authentication.m @@ -194,19 +194,14 @@ static OSStatus AuthorizationExecuteWithPrivilegesAndWait( - (BOOL)copyPath:(NSString *)src overPath:(NSString *)dst withAuthentication:(BOOL)useAuthentication { - NSLog(@"Copying %@ to %@...", dst, [self _temporaryCopyNameForPath:dst]); if ([[NSFileManager defaultManager] isWritableFileAtPath:dst] && [[NSFileManager defaultManager] isWritableFileAtPath:[dst stringByDeletingLastPathComponent]]) { NSInteger tag = 0; BOOL result; NSString *tmpPath = [self _temporaryCopyNameForPath:dst]; - NSLog(@"Performing traditional copy from %@ to %@...", src, dst); result = [[NSFileManager defaultManager] movePath:dst toPath:tmpPath handler:self]; - NSLog(@"Moving %@ to %@...", src, dst); result &= [[NSFileManager defaultManager] copyPath:src toPath:dst handler:nil]; - NSLog(@"Moving %@ to the trash...", tmpPath); - result &= [[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:tmpPath destination:@"" files:[NSArray arrayWithObject:[tmpPath lastPathComponent]] tag:&tag]; - NSLog(@"Success!"); + result &= [[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[tmpPath stringByDeletingLastPathComponent] destination:@"" files:[NSArray arrayWithObject:[tmpPath lastPathComponent]] tag:&tag]; // If the currently-running application is trusted, the new // version should be trusted as well. Remove it from the diff --git a/SUUpdater+Authentication.m b/SUUpdater+Authentication.m deleted file mode 100644 index d888c11c..00000000 --- a/SUUpdater+Authentication.m +++ /dev/null @@ -1,58 +0,0 @@ -// -// SUUpdater+Authentication.m -// Pixen -// -// Created by Andy Matuschak on 3/9/06. -// Copyright 2006 __MyCompanyName__. All rights reserved. -// - -#import "Sparkle.h" -#import "SUUpdater.h" - -#import -#import -#import -#import - -@implementation SUUpdater (SUAuthenticationAdditions) - -// Thanks to Allan Odgaard for this! -- (BOOL)moveFileWithAuthenticationFrom:(NSString *)src toNewPath:(NSString *)dst withTempPath:(NSString *)tmp -{ - BOOL res = NO; - struct stat sb; - if((stat([src UTF8String], &sb) != 0) || (stat([tmp UTF8String], &sb) == 0) || stat([dst UTF8String], &sb) != 0) - return false; - - char* buf = NULL; - asprintf(&buf, - "mv -f \"$DST_PATH\" \"$TMP_PATH\" && " - "mv -f \"$SRC_PATH\" \"$DST_PATH\" && " - "rm -rf \"$TMP_PATH\" && " - "chown -R %d:%d \"$DST_PATH\"", - sb.st_uid, sb.st_gid); - - if(!buf) - return false; - - AuthorizationRef auth; - if(AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &auth) == errAuthorizationSuccess) - { - setenv("SRC_PATH", [src UTF8String], 1); - setenv("DST_PATH", [dst UTF8String], 1); - setenv("TMP_PATH", [tmp UTF8String], 1); - - char const* arguments[] = { "-c", buf, NULL }; - if(AuthorizationExecuteWithPrivileges(auth, "/bin/sh", kAuthorizationFlagDefaults, (char**)arguments, NULL) == errAuthorizationSuccess) - { - int status; - int pid = wait(&status); - if(pid != -1 && WIFEXITED(status) && WEXITSTATUS(status) == 0) - res = YES; - } - } - free(buf); - return res; -} - -@end