• 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: Unable to unload Launch Daemon using Cocoa Application.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unable to unload Launch Daemon using Cocoa Application.


  • Subject: Re: Unable to unload Launch Daemon using Cocoa Application.
  • From: JanakiRam <email@hidden>
  • Date: Sun, 23 Mar 2008 19:30:51 +0530

It seems no one had came across such a situation. Can any one from apple
help me ?

 Please help me to solve this problem. Thanks in Advance.

-JanakiRam.

On 3/22/08, JanakiRam <email@hidden> wrote:
>
> Hi All,
>
>        I'm developing a cocoa application which needs to unload my Launch
> Daemon for one particular requirement. I've used Authorization Services to
> perform unload of Launch Daemon ( previlaged action ). But couldn't succeed
> in this. I'm getting the following error on executed  my code.
>
> *Output :*
> **
> *lauchctl : Error in unloading mydaemon*
> **
> *Note :* Attaching my code snippet for your reference.
>
>           Please help me to solve this problem. Thanks in Advance.
>
> -JanakiRam
>
>  *Code Snippet :*
> **
> *- (void) UnloadDaemon
> {
>     // setup our authorization environment.
>     AuthorizationItem authItems[1];  // we only want to get authorization
> for one command
>     BOOL authorized = NO;  // are we authorized?
>     char *args[4];
>
>     char *command = "/bin/launchctl";
>
>     authItems[0].name = kAuthorizationRightExecute; // we want the right
> to execute
>     authItems[0].value = command;  // the path to the startup script
>     authItems[0].valueLength = strlen(command); // length of the command
>     authItems[0].flags = 0;    // no extra flags
>
>     authRights.count = 1;  // we have one item
>     authRights.items = authItems; // here is the values for our item
>
>     authFlags = kAuthorizationFlagInteractionAllowed |
> kAuthorizationFlagExtendRights;
>
>     // lets find out if we are authorized
>
>     ourStatus = AuthorizationCopyRights(authorizationRef,&authRights,
>                 kAuthorizationEmptyEnvironment, authFlags, NULL);
>
>     authorized = (errAuthorizationSuccess==ourStatus);
>
>     if (authorized)
>     {
>         // we are authorized, so let's tell the security framework to
> execute
>         // our command as root
>   args[0] = "unload";
>         args[1] = "-w";
>   args[2] = "/Library/LaunchDaemons/org.mycompany.launchdaemon.plist";
>   args[3] = NULL;
>
>         ourStatus = AuthorizationExecuteWithPrivileges(authorizationRef,
>                                              command,
>                                              kAuthorizationFlagDefaults,
> args, NULL);
>
>         if(ourStatus != errAuthorizationSuccess)
>         {
>             NSLog(@"unload has failed");
>         }
>     }
>     else
>     {
>       NSLog(@"error in authentication");
>     }
> }*
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Unable to unload Launch Daemon using Cocoa Application.
      • From: Jens Alfke <email@hidden>
References: 
 >Unable to unload Launch Daemon using Cocoa Application. (From: JanakiRam <email@hidden>)

  • Prev by Date: Re: NSImage > trapezium...
  • Next by Date: Re: NSImage > trapezium...
  • Previous by thread: Unable to unload Launch Daemon using Cocoa Application.
  • Next by thread: Re: Unable to unload Launch Daemon using Cocoa Application.
  • Index(es):
    • Date
    • Thread