From 61e16cf2762d2d555e4392ddfed0e44cecdbfa46 Mon Sep 17 00:00:00 2001 From: Dmytro Tretiakov Date: Mon, 14 Jul 2014 13:54:47 +0300 Subject: [PATCH] Removed compile warnings. --- SUDSAVerifier.m | 5 +++++ SUPlainInstallerInternals.m | 31 ++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/SUDSAVerifier.m b/SUDSAVerifier.m index eb4dd2ff..9d63695e 100644 --- a/SUDSAVerifier.m +++ b/SUDSAVerifier.m @@ -11,6 +11,9 @@ #import +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + /* CDSA Specific */ static CSSM_CSP_HANDLE cdsaInit( void ); static void cdsaRelease( CSSM_CSP_HANDLE cspHandle ); @@ -355,3 +358,5 @@ static Boolean su_copyBytesToData( CSSM_DATA_PTR data, CSSM_SIZE size, const uin } return retval; } + +#pragma GCC diagnostic pop diff --git a/SUPlainInstallerInternals.m b/SUPlainInstallerInternals.m index ae608290..76b51a1d 100644 --- a/SUPlainInstallerInternals.m +++ b/SUPlainInstallerInternals.m @@ -22,7 +22,7 @@ #import #import #import - +#import @interface SUPlainInstaller (MMExtendedAttributes) // Removes the directory tree rooted at |root| from the file quarantine. @@ -55,15 +55,40 @@ static BOOL SUAuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authori sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL); BOOL returnValue = YES; - if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, (char* const*)arguments, NULL) == errAuthorizationSuccess) + // Create func pointer to AuthorizationExecuteWithPrivileges in case it doesn't exist + // in this version of MacOS + static OSStatus (*_AuthExecuteWithPrivilegesFunc)(AuthorizationRef authorization, + const char *pathToTool, + AuthorizationFlags options, + char * const *arguments, + FILE **communicationsPipe) = NULL; + + // Check to see if we have the correct function in our loaded libraries + if (NULL == _AuthExecuteWithPrivilegesFunc) + { + // On 10.7, AuthorizationExecuteWithPrivileges is deprecated. We want + // to still use it since there's no good alternative (without requiring + // code signing). We'll look up the function through dyld and fail if + // it is no longer accessible. If Apple removes the function entirely + // this will fail gracefully. If they keep the function and throw some + // sort of exception, this won't fail gracefully, but that's a risk + // we'll have to take for now. + // Pattern by Andy Kim from Potion Factory LLC + _AuthExecuteWithPrivilegesFunc = dlsym(RTLD_DEFAULT, "AuthorizationExecuteWithPrivileges"); + } + + if (NULL != _AuthExecuteWithPrivilegesFunc && + errAuthorizationSuccess == _AuthExecuteWithPrivilegesFunc(authorization, executablePath, options, (char* const*)arguments, NULL)) { - int status; + int status = 0; pid_t pid = wait(&status); if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) returnValue = NO; } else + { returnValue = NO; + } signal(SIGCHLD, oldSigChildHandler); return returnValue;