diff --git a/stepmania/PBProject/Installer/BuildInstaller.cpp b/stepmania/PBProject/Installer/BuildInstaller.cpp index d7c495840d..eb2aa30ada 100644 --- a/stepmania/PBProject/Installer/BuildInstaller.cpp +++ b/stepmania/PBProject/Installer/BuildInstaller.cpp @@ -24,7 +24,8 @@ using namespace std; #include "Processor.h" #include "Util.h" -void HandleFile(const CString& file, const CString& dir, const CString& archivePath, bool overwrite) +void HandleFile(const CString& file, const CString& dir, + const CString& archivePath, bool overwrite) { static bool archiveMade = false; char path[] = "/usr/bin/tar"; @@ -44,8 +45,6 @@ void HandleFile(const CString& file, const CString& dir, const CString& archiveP strcpy(arg4, dir); strcpy(arg5, file); - /*if (CallTool(path, arg1, arg2, arg3, arg4, arg5, NULL)) - exit(-10);*/ int r; if ((r = CallTool2(true, -1, -1, -1, path, arg1, arg2, arg3, arg4, arg5, NULL)) != 0) diff --git a/stepmania/PBProject/Installer/Helper.mm b/stepmania/PBProject/Installer/Helper.mm index da36047602..e1ffd693ab 100644 --- a/stepmania/PBProject/Installer/Helper.mm +++ b/stepmania/PBProject/Installer/Helper.mm @@ -6,8 +6,6 @@ // Copyright (c) 2003 Steve Checkoway. All rights reserved. // -#import -#import #import #import #import @@ -22,14 +20,14 @@ void Error(const char *fmt, ...); static id c; -static AuthorizationRef auth; -static BOOL privilegedInstall; -void HandleFile(const CString& file, const CString& dir, const CString& archivePath, bool overwrite) +void HandleFile(const CString& file, const CString& dir, + const CString& archivePath, bool overwrite) { NSString *filePath = [NSString stringWithCString:dir]; - filePath = [filePath stringByAppendingFormat:@"%s%s", (dir == "/" ? "" : "/"), file.c_str()]; + filePath = [filePath stringByAppendingFormat:@"%s%s", + (dir == "/" ? "" : "/"), file.c_str()]; if (!overwrite && DoesFileExist([filePath cString])) return; [c postMessage:filePath]; @@ -46,32 +44,11 @@ void HandleFile(const CString& file, const CString& dir, const CString& archiveP strcpy(d, dir); strcpy(f, file); - if (privilegedInstall) - { - AuthorizationFlags flags = kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | - kAuthorizationFlagExtendRights; - AuthorizationItem item = {kAuthorizationRightExecute, 0, NULL, 0}; - AuthorizationRights rights = {1, &item}; - OSStatus status = AuthorizationCopyRights(auth, &rights, NULL, flags, NULL); + int fd_dev_null = open("/dev/null", O_RDWR, 0); - if (status != errAuthorizationSuccess) - { - [c postMessage:@"Couldn't authorize"]; - return; - } - status = AuthorizationExecuteWithPrivileges(auth, path, kAuthorizationFlagDefaults, arguments+1, NULL); - if (status != errAuthorizationSuccess) - [c postMessage:@"failed"]; - wait((int*)&status); - } - else - { - int fd_dev_null = open("/dev/null", O_RDWR, 0); - - if (CallTool3(true, -1, fd_dev_null, fileno(stderr), path, arguments)) - [c postMessage:@"failed"]; - close(fd_dev_null); - } + if (CallTool3(true, -1, fd_dev_null, fileno(stderr), path, arguments)) + [c postMessage:@"failed"]; + close(fd_dev_null); } const CString GetPath(const CString& ID) @@ -84,8 +61,8 @@ const CString GetPath(const CString& ID) [panel setAllowsMultipleSelection:NO]; [panel setPrompt:@"Install"]; // Only in 10.3 and above - if ([panel respondsToSelector:@selector(setCanCreatetDirectories:)]) - [panel setCanCreateDirectories:YES]; + if ([panel respondsToSelector:@selector(setCanCreateDirectories:)]) + [panel setCanCreateDirectories:YES]; [panel setTitle:@"Choose a location to install."]; int result = [panel runModalForTypes:[NSArray array]]; // No extensions @@ -122,16 +99,6 @@ bool AskFunc(const CString& question) return answer; } -bool Auth(void) -{ - AuthorizationFlags flags = kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | - kAuthorizationFlagPreAuthorize | kAuthorizationFlagExtendRights; - AuthorizationItem item = {kAuthorizationRightExecute, 0, NULL, 0}; - AuthorizationRights rights = {1, &item}; - OSStatus status = AuthorizationCopyRights(auth, &rights, NULL, flags, NULL); - return status == errAuthorizationSuccess; -} - void Echo(const CString& message, bool loud) { if (!loud) @@ -142,13 +109,7 @@ void Echo(const CString& message, bool loud) NSBeginCriticalAlertSheet(@"Warning", @"OK", nil, nil, [c window], c, nil, nil, NULL, [NSString stringWithCString:message.c_str()]); -} - -void Priv(bool privileged) -{ - privilegedInstall = privileged; -} - +} @implementation Helper - (id)initWithPath:(NSString *)path @@ -156,24 +117,11 @@ void Priv(bool privileged) [super init]; mPath = [path retain]; - OSStatus status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, - kAuthorizationFlagDefaults, &auth); - if (status != errAuthorizationSuccess) - { - auth = NULL; - [self autorelease]; - return nil; - } - - privilegedInstall = NO; - return self; } - (void)dealloc { - if (auth) - AuthorizationFree(auth, kAuthorizationFlagDestroyRights); [mPath autorelease]; [super dealloc]; } @@ -194,9 +142,7 @@ void Priv(bool privileged) Processor p(archivePath, HandleFile, GetPath, AskFunc, YES); p.SetErrorFunc(Error); - p.SetAuthFunc(Auth); p.SetEchoFunc(Echo); - p.SetPrivFunc(Priv); [c postMessage:@"Reading from the config file."]; diff --git a/stepmania/PBProject/Installer/Processor.cpp b/stepmania/PBProject/Installer/Processor.cpp index b72ced57e0..9c89bc941b 100644 --- a/stepmania/PBProject/Installer/Processor.cpp +++ b/stepmania/PBProject/Installer/Processor.cpp @@ -109,41 +109,121 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine) #pragma mark FILE if (parts[0] == "FILE") { - if (parts.size() != 3) - goto error; - CString file, dir; - if (parts[1][0] == '/') - { - file = parts[1].substr(1); - dir = "/"; - } - else - { - file = parts[1]; - dir = mCWD; - } + if (parts.size() == 3) + { + CString file, dir; + if (parts[1][0] == '/') + { + file = parts[1].substr(1); + dir = "/"; + } + else + { + file = parts[1]; + dir = mCWD; + } - if (mInstalling) - (*mHandleFile)(file, dir, mPath, ResolveConditional(parts[2])); - else - { - CStringArray list, dirs; - if (IsADirectory((dir == "/" ? dir : dir + "/" ) + file)) - { - int fd = open(".", O_RDONLY, 0); + if (mInstalling) + (*mHandleFile)(file, dir, mPath, ResolveConditional(parts[2])); + else + { + if (IsADirectory((dir == "/" ? dir : dir + "/" ) + file)) + { + CStringArray list, dirs; + int fd = open(".", O_RDONLY, 0); - chdir(dir); - FileListingForDirectoryWithIgnore(file, list, dirs, mIgnore); - fchdir(fd); - close(fd); - if (list.size() == 0) //empty directory or ignored directory - (*mHandleFile)(file, dir, mPath, true); - for (unsigned i=0; i mReturnStack; bool mDoGoto; @@ -41,9 +39,7 @@ private: getPathFunc mGetPath; askFunc mAsk; errorFunc mError; - authFunc mAuth; - echoFunc mEcho; - privFunc mPriv; + echoFunc mEcho; bool mInstalling; const CString& ResolveVar(const CString& var); @@ -54,9 +50,7 @@ public: ~Processor(); void ProcessLine(const CString& line, unsigned& nextLine); void SetErrorFunc(errorFunc f) { mError = f; } - void SetAuthFunc(authFunc f) { mAuth = f; } void SetEchoFunc(echoFunc f) { mEcho = f; } - void SetPrivFunc(privFunc f) { mPriv = f; } }; #endif