objective c - Multiple sudo commands in cocoa -


After reading something, I finally found out how to order sudo through cocoa, but when I made several commands I try, it does only for the first time my code: authorization referee REF; Ossetatus status; Status = Create authorization (authorization of zero, authorization of empty environment environment, flag defaults, and authorization reef); / * One step: rename / replace name of existing garbage icon files trashempty icon NSLog (@ "Renaming trashempty icon"); Char * trashempty_tool = "/ bin / mv"; Char * trashempty_args [] = {"/ system / library / coir services / doc.app / content / resource character /trashempty.png", "/ System / Library / CoreServices / Dock.app / Contents / Resources / trashempty_backup.png" }; Status = Authorization ExecuteWithPrivileges (Authority Reef, trashempty_tool, kAuthorizationFlagDefaults, trashempty_args, NULL); NSLog (@ "authorization result code:% d", position); // Check for TODO NSLog Status (@ "Rename the Trashful Icon"); Char * trashfull_tool = "/ bin / mv"; Char * trashfull_args [] = {"/System/Library/CoreServices/Dock.app/Contents/Resources/trashfull.png", "/ System / Library / CoreServices / Dock.app / Contents / Resources / trashfull_backup.png"}; Status = authorization ExecuteWithPrivileges (authorizationRef, trashfull_tool, kAuthorizationFlagDefaults, trashfull_args, NULL); NSLog (@ "authorization result code:% d", position);

Can you help me?

It is recommended that you build helpful applications placed in your main bundled resource,

Ie you put MV code in the assist application, and use the authorization in the main app to run it.

Doing this will allow the assist app to run with auth. And writing code for MV will be easy. If you can if you want to use Anstisk to MV job Mddkrta AP.

You can get the path of the supporting application and convert it to the RG.

  Ansbindl * bundle = [Ansbindl bundle Foreksas: [self class]]; NSString * helpPath = [[Bundle Processing Path] stringByAppendingString: @ "/ HelperApp"]; Const char * helperpath; Helperpath = [helpPath cStringUsingEncoding: NSUTF8StringEncoding];   

or call helperpath in AuthorizationExecuteWithPrivileges

Docs in Apple be about how this is an example.

Comments