• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Running process as root from Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Running process as root from Cocoa
      • From: Bill Bumgarner <email@hidden>
    • Re: Running process as root from Cocoa
      • From: "Kyle Sluder" <email@hidden>
References: 
 >Running process as root from Cocoa (From: "Mitchell Hashimoto" <email@hidden>)

  • Prev by Date: Re: NSTextField value binding and button click
  • Next by Date: Re: Subclassing NSTextFieldCell
  • Previous by thread: Re: Getting called back when an NSScrollView is scrolled
  • Next by thread: Re: Running process as root from Cocoa
  • Index(es):
    • Date
    • Thread