• 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: How to detect when a AuthorizationExecuteWithPrivileges process has finished
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to detect when a AuthorizationExecuteWithPrivileges process has finished


  • Subject: Re: How to detect when a AuthorizationExecuteWithPrivileges process has finished
  • From: Stéphane Sudre <email@hidden>
  • Date: Mon, 23 Jun 2003 16:24:10 +0200

On lundi, juin 23, 2003, at 16:10 Europe/Paris, Zeno Crivelli wrote:

How to detect when a process - launched with
"AuthorizationExecuteWithPrivileges" from Security.framework - has
finished?

Does the "AuthorizationExecuteWithPrivileges" function return
immediately or after the execution is completed?

It returns immediately.

If it returns immediately then how does one know when it completes?

Nothing prevents you to add a Distributed NotificationCenter to the
main application and then send a notification from the launched process
to say: "Done!".

Yes, but HOW can I detect the end of that launched process?

If I would use NSTask, I would add:

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(finishedTask:)
name:NSTaskDidTerminateNotification
object:nil];

And then I would implement the finishedTask: method...


But I canNOT find the equivalent of "NSTaskDidTerminateNotification" in the
AuthorizationExecuteWithPrivileges method.

That's my problem...

The idea I was suggesting is to send the notification from the launched process by adding some code when it ends.

In your main application, you add:

[[NSDistributedNotificationCenter defaultCenter] addObserver:self
selector:@selector(finishedTask:)
name:@"MYTOOLHASFINISHEDITSTASK"
object:nil];


and in the tool:

[[NSDistributedNotificationCenter defaultCenter] postNotificationName: @"MYTOOLHASFINISHEDITSTASK" object:nil userInfo:nil deliverImmediately:YES];

If you can't change the tool source code, then a solution is to instead launch via the executeWithPrivileges[...] an intermediate Cocoa tool whose sole purpose is to launch this tool and that is going to send a distributed notification on finishedTask:.

To sum-up:

1st case (you can modify the tool source and it's at least a Foundation tool or a CoreFoundation one):
------------------------------------------------------------------------ ------------------------------

Add an observer in the main application

Send the notification from the tool

2nd case (you can't modify the tool):
-------------------------------------

Add an observer in the main application

Create a Foundation tool which looks like this:

NSTaskDidTerminateNotification_catcher()
{
send a notification to the main application via the NSDistributedNotificationCenter
quit the tool.
}

main()
{
Register for NSTaskDidTerminateNotification
Create a task to launch the final tool
launch the task
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: How to detect when a AuthorizationExecuteWithPrivileges process has finished (From: Zeno Crivelli <email@hidden>)

  • Prev by Date: Re: How to detect when a AuthorizationExecuteWithPrivileges process has finished
  • Next by Date: Re: Adding subview
  • Previous by thread: Re: How to detect when a AuthorizationExecuteWithPrivileges process has finished
  • Next by thread: Adding subview
  • Index(es):
    • Date
    • Thread