Re: SFAuthorization

2009-11-16 Thread Nyxem
Ok, thanks for helping me Kyle. I'll take a look to BetterAuthorizationSample 
code.

Nyxem

On Nov 16, 2009, at 8:13 AM, Kyle Sluder wrote:

> On Sun, Nov 15, 2009 at 10:39 AM, nyx...@gmail.com  wrote:
>> If i understood correctly, the function AuthorizationExecuteWithPrivileges() 
>> executes the given command in a new process.
>> 
>> Is there a way to wait for the created process to terminate ?
> 
> No, using AEWP correctly will always create a zombie:
> http://lists.apple.com/archives/cocoa-dev/2008/Oct/msg00195.html
> 
> --Kyle Sluder

___

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


Re: NSWorkspace in a daemon

2009-11-30 Thread Nyxem
I found something that said to use NSApplicationLoad() and it seems to work.

Nyxem.


On Nov 30, 2009, at 4:25 PM, Bill Garrison wrote:

> 
> On Nov 30, 2009, at 9:17 AM, Nyxouf da ouf wrote:
> 
>> Hi,
>> 
>> I have an Obj-c program who run as a daemon, using launchd, and that look
>> for NSWorkspaceDidMountNotification.
>> 
>> *[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
>> selector:@selector(diskDidMount:) name:NSWorkspaceDidMountNotification
>> object:nil];*
>> -(void)diskDidMount:(NSNotification*)notif
>> {
>> NSLog(@"disk did mount");
>> }
>> 
>> My problem is that when the daemon is launched as root the notification
>> isn't catched, how can I solve this ?
> 
> This probably has something to do with Mach namespaces.
> 
> <http://developer.apple.com/mac/library/technotes/tn2005/tn2083.html#SECMACHBOOTSTRAPBASICS>
> 
> The daemon launched as root gets its own Mach namespace, separate from other 
> user-level processes on the box.  The NSWorkspaceDidMountNotification 
> probably won't cross the Mach namespace boundary between the root-based 
> daemon and other user-level apps that might be listening for it.
> 
> Bill
> ___
> 
> 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/nyx0uf%40gmail.com
> 
> This email sent to nyx...@gmail.com

___

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


Re: NSWorkspace in a daemon

2009-11-30 Thread Nyxem
So what is the right way to do this ?

Nyxem.

On Nov 30, 2009, at 4:37 PM, Jean-Daniel Dupas wrote:

> 
> Le 30 nov. 2009 à 16:25, Bill Garrison a écrit :
> 
>> 
>> On Nov 30, 2009, at 9:17 AM, Nyxouf da ouf wrote:
>> 
>>> Hi,
>>> 
>>> I have an Obj-c program who run as a daemon, using launchd, and that look
>>> for NSWorkspaceDidMountNotification.
>>> 
>>> *[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
>>> selector:@selector(diskDidMount:) name:NSWorkspaceDidMountNotification
>>> object:nil];*
>>> -(void)diskDidMount:(NSNotification*)notif
>>> {
>>> NSLog(@"disk did mount");
>>> }
>>> 
>>> My problem is that when the daemon is launched as root the notification
>>> isn't catched, how can I solve this ?
>> 
>> This probably has something to do with Mach namespaces.
>> 
>> <http://developer.apple.com/mac/library/technotes/tn2005/tn2083.html#SECMACHBOOTSTRAPBASICS>
>> 
>> The daemon launched as root gets its own Mach namespace, separate from other 
>> user-level processes on the box.  The NSWorkspaceDidMountNotification 
>> probably won't cross the Mach namespace boundary between the root-based 
>> daemon and other user-level apps that might be listening for it.
>> 
>> Bill
> 
> AppKit is not daemon safe.
> 
> http://developer.apple.com/mac/library/technotes/tn2005/tn2083.html#SECLIVINGDANGEROUSLY
> 
> 
> -- Jean-Daniel
> 
> 
> 
> 
> ___
> 
> 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/nyx0uf%40gmail.com
> 
> This email sent to nyx...@gmail.com

___

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


Launch process as root from cocoa app

2010-01-25 Thread Nyxem
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


Re: Launch process as root from cocoa app

2010-01-27 Thread Nyxem
It didn't work, I'm gonna try the solution given by Kyle Sluder, with the 
KeepAlive options of launchd.plist.

On Jan 27, 2010, at 4:34 AM, Charles Srstka wrote:

> On Jan 25, 2010, at 9:18 PM, Nick Zitzmann wrote:
> 
>> 
>> On Jan 25, 2010, at 12:57 AM, Nyxem wrote:
>> 
>>> 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.
>> 
>> As you've figured out, AEWP() launches apps with root privileges, but it 
>> doesn't run them _as_ root. If you need to launch an app as root for 
>> whatever reason via AEWP(), then search the archives for a workaround, 
>> because I'm pretty sure I've posted at least one workaround for this years 
>> ago...
>> 
>> Nick Zitzmann
>> <http://www.chronosnet.com/>
> 
> It launches the process with an *effective* UID of root. You should be able 
> to make it run as root by using the setuid() function.
> 
> However, a better way to go would probably be to use the BetterAuthSample 
> code.
> 
> Charles

___

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