Running sh script through AuthorizationExecuteWithPrivileges

I am running an application to remove a script through cocoa, and I noticed that the launchctl command is not executing.

This is part of the code that invokes the script (which contains sudo launchctl unload "daemon name")

//pFileName is the name of the File

NSString* pPath = [pCurrentBundle pathForResource:pFileName ofType:@"sh"];
char* const ppArgs[] = {const_cast<char*>([pPath fileSystemRepresentation]), NULL};

OSStatus status =  AuthorizationExecuteWithPrivileges(m_AuthorizationRef, "/bin/sh", kAuthorizationFlagDefaults, ppArgs, NULL); 

Since all other script commands are executed properly (and it is unloaded in the terminal), I assume that I do not have the same privileges as root (both EUID and RUID are 0), as indicated in TN2083.

+3
source share
1 answer

-, sudo script, root. Mac , , sudoers. , .

, ? , ; ? unix script?

, .

, script, , .sh, pFileName .sh.

TN2083 AuthorizationExecuteWithPrivileges. " TN2083"?

, setuid, script, ? AuthorizationExecuteWithPrivileges.

0

Source: https://habr.com/ru/post/1713202/


All Articles