• 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
Run Bash script as root
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Run Bash script as root


  • Subject: Run Bash script as root
  • From: Jerry Brace <email@hidden>
  • Date: Wed, 10 Aug 2005 19:14:25 -0230

I'm trying to run a bash script as root - I am prompting for authentication - all of that works great. When it comes time to run the script it doesn't seem to do anything (not writing out the echo text I have in the script). Even if I put in an invalid name for the resource (wakeup.sh) it doesn't throw an error and still prompts correctly for the password. Any help would be great!

- (void)setValue:(NSString*)inValue forVariable:(NSString*)inVariable
{
NSBundle *thisBundle = [NSBundle bundleForClass:[self class]];
NSMutableString * path = [thisBundle pathForResource:@"wakeup" ofType:@"sh"];


    char* args[1];
    OSStatus err = 0;

    if(![self authenticate])
        return;

    //the arguments parameter to AuthorizationExecuteWithPrivileges is
    //a NULL terminated array of C string pointers.
    args[0] = NULL;

    FILE *myCommunicationsPipe = NULL;

    AuthorizationFlags myFlags = kAuthorizationFlagDefaults;

err = AuthorizationExecuteWithPrivileges(authorizationRef,
[path cString],
myFlags, NULL, &myCommunicationsPipe);
if(err!=0)
{
NSBeep();
NSLog(@"Error %d in AuthorizationExecuteWithPrivileges",err);
}
}


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Run Bash script as root
      • From: Tom Harrington <email@hidden>
  • Prev by Date: Re: Interface mockups
  • Next by Date: NSNotifications between threads
  • Previous by thread: Re: Spotlight Importers for non-Doc Core Data Application?
  • Next by thread: Re: Run Bash script as root
  • Index(es):
    • Date
    • Thread