mirror of https://github.com/ksherlock/ample.git
silly tweaks for the auth commands.
When stepping in the debugger, it works fine. When running normally, the second command has a tendency not to run. adding a file pointer AND reading from it seems to allow the second command to run more consistently.
This commit is contained in:
parent
6e7acb88e2
commit
f3137585c1
|
@ -144,12 +144,23 @@
|
|||
kAuthorizationEmptyEnvironment, myFlags, NULL);
|
||||
|
||||
if (!myStatus) {
|
||||
FILE *fp = NULL;
|
||||
static char buffer[4096];
|
||||
const char *cp = [path fileSystemRepresentation];
|
||||
const char* args_chown[] = {"root", cp , NULL};
|
||||
const char* args_chmod[] = {"+s", cp, NULL};
|
||||
myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef, "/usr/sbin/chown", kAuthorizationFlagDefaults, (char**)args_chown, NULL);
|
||||
myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef, "/bin/chmod", kAuthorizationFlagDefaults, (char**)args_chmod, NULL);
|
||||
|
||||
// well ... the second command executes a lot more consistently when the (optional) fp is provided and the we fgets the buffer.
|
||||
myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef, "/usr/sbin/chown", kAuthorizationFlagDefaults, (char**)args_chown, &fp);
|
||||
fgets(buffer, sizeof(buffer), fp);
|
||||
fclose(fp);
|
||||
// fprintf(stderr, "myStatus = %d\ndata: %s\n", myStatus, buffer);
|
||||
|
||||
myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef, "/bin/chmod", kAuthorizationFlagDefaults, (char**)args_chmod, &fp);
|
||||
fgets(buffer, sizeof(buffer), fp);
|
||||
fclose(fp);
|
||||
// fprintf(stderr, "myStatus = %d\ndata: %s\n", myStatus, buffer);
|
||||
|
||||
}
|
||||
AuthorizationFree(myAuthorizationRef, kAuthorizationFlagDestroyRights);
|
||||
|
||||
|
|
Loading…
Reference in New Issue