Run Bash script as root
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