Hello,

I'm currently working on a Preference Pane with an SFAuthorizationView, my 
problem is simple, when I click on a switch button I need to start / stop a 
daemon as user using launchctl.
I tried 3 different ways and the only one that is working is the slowest, here 
the 3 ways I tried :

1 - Using the authorizationRef object of my SFAuthorizationView and call 
AuthorizationExecuteWithPrivileges() ("/bin/launchctl load 
/Library/LaunchDaemons/com.mydaemon.plist")
        --> Failed. daemon not launched as root, but as current user.

2 - Using /usr/bin/security with an NSTask : "/usr/bin/security 
execute-with-privileges /bin/launchctl load 
/Library/LaunchDaemons/com.mydaemon.plist"
        --> Failed. daemon not launched as root, but as current user + ask a 
second time for an admin password..

3 - Using AppleScript :
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:@"do shell script 
\"/bin/launchctl load /Library/LaunchDaemons/com.mydaemon.plist\" with 
administrator privileges"];
NSDictionary *errorInfo;
[script executeAndReturnError:&errorInfo];
[script release];
        --> Worked but very slow and I have to re-enter an admin password, 
which is very annoying.

So is there any other way to do this without enter 2 times an admin password ?

Thanks for your help.

Nyxem.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to