• 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: Problems running a shell script as root
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems running a shell script as root


  • Subject: Re: Problems running a shell script as root
  • From: Brian Smith <email@hidden>
  • Date: Fri, 27 Jul 2007 11:49:55 -0600


On Jul 27, 2007, at 11:26 AM, deepak gopal wrote:

I am using AuthorizationExecuteWithPrivileges to run a shell script which needs root privileges. I can execute the shell scripts as a local user, but can't run scripts which need root privileges.
I read through many doc's on the net and the guides in developer.apple.com since yesterday, and haven't found an answer yet.


Please advice.

-------------  the code --------------------------
AuthorizationRef authRef_;
NSString *pathToTool = @"/bin/sh";
NSString *filePath3 = @"~/Desktop/AUTOscript/loadApp.sh";

argsArray3[0] = "-p";
argsArray3[1] = (char *)[[filePath3 stringByExpandingTildeInPath] fileSystemRepresentation];
argsArray3[2] = NULL;


OSStatus status3 = AuthorizationExecuteWithPrivileges(authRef_, [pathToTool UTF8String], 0, argsArray3 , NULL);



You have created an empty AuthorizationRef structure without getting any authorization data or actually authorizing the operation. Look at the "Authorization Services C Reference" or "Performing Privileged Operations With Authorization Services" documents on how to do this.


Brian
_______________________________________________

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: Problems running a shell script as root
      • From: deepak gopal <email@hidden>
References: 
 >Problems running a shell script as root (From: deepak gopal <email@hidden>)

  • Prev by Date: Problems running a shell script as root
  • Next by Date: Re: Usefulness of a Cocoa DSP framework?
  • Previous by thread: Problems running a shell script as root
  • Next by thread: Re: Problems running a shell script as root
  • Index(es):
    • Date
    • Thread