Re: Running process as root from Cocoa
Re: Running process as root from Cocoa
- Subject: Re: Running process as root from Cocoa
- From: Nir Soffer <email@hidden>
- Date: Mon, 28 Jan 2008 23:48:23 +0200
On Jan 28, 2008, at 19:17, Mitchell Hashimoto wrote:
I am trying to run some code with root priveleges, specifically to use
task_for_pid to modify (read/write) another process's memory. The
reasoning behind this is that this application is a game trainer. I am
able to get it to work by launching the program with "sudo" but this
is a pain. is there any way to run the program and have an
"authorization" box pop up and ahve the user authorize the actions?
The simplest solution is:
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:
@"do shell script 'path/to/exeutable' with administrator privileges"];
NSDictionary *errorInfo;
[script executeAndReturnError:&errorInfo];
You will get an auth dialog - when the user will enter an
administrator name and password, "/path/to/exeutable" will run as root.
On Leopard, you can also use the security tool:
/usr/bin/security execute-with-privileges /path/to/executable
You can run this with NSTask.
Best Regards,
Nir Soffer
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden