• 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
AuthorizationExecuteWithPrivileges with execution failure error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AuthorizationExecuteWithPrivileges with execution failure error


  • Subject: AuthorizationExecuteWithPrivileges with execution failure error
  • From: Appa Rao Mulpuri <email@hidden>
  • Date: Wed, 23 Jul 2014 13:34:18 +0000
  • Thread-topic: AuthorizationExecuteWithPrivileges with execution failure error

Hi,

Any idea why following code always returning errAuthorizationToolExecuteFailure (-60031). Tried multiple combination of flags, but no luck.

    // Create authorization reference
    OSStatus status;
    AuthorizationRef authorizationRef;
    // kAuthorizationRightExecute == "system.privilege.admin"
    AuthorizationItem right = {kAuthorizationRightExecute, 0, NULL, 0};
    AuthorizationRights rights = {1, &right};
    AuthorizationFlags flags = kAuthorizationFlagDefaults |
    kAuthorizationFlagInteractionAllowed |
    kAuthorizationFlagExtendRights;



    NSString *promptText = @"Custom text displaying in the dialog.\n\n";



    AuthorizationItem dialogConfiguration[1] = { kAuthorizationEnvironmentPrompt, [promptText length], (char *) [promptText UTF8String], 0 };



    AuthorizationEnvironment authorizationEnvironment = { 0 };
    authorizationEnvironment.items = dialogConfiguration;
    authorizationEnvironment.count = 1;



    // Open dialog and prompt user for password
    status = AuthorizationCreate(&rights, &authorizationEnvironment, flags, &authorizationRef);
    NSLog(@"Initial Authorization: %d", (int)status);
    FILE *pipe = NULL;
    if (status == errAuthorizationSuccess)
    {
            char *cpTool = (char *)[@"cp Rf" UTF8String]; //Running this code in the sample user. And myApp.app has the Read&write permissions
        char *cpToolArgs[] = {(char *)[@"/Users/sample/Desktop/myApp.app" UTF8String], (char *)[@"/Applications" UTF8String], NULL};

            status = AuthorizationExecuteWithPrivileges(authorizationRef, cpTool,
                                                        kAuthorizationFlagDefaults, cpToolArgs, &pipe);
            NSLog(@"cpTool:%s Args:%s  %s", cpTool, cpToolArgs[0], cpToolArgs[1]);
            if (status != errAuthorizationSuccess)
                NSLog(@"Error: %d", (int)status);
    }


Regards,
Apparao Mulpuri
This email and any attachments are confidential, and may be legally privileged and protected by copyright. If you are not the intended recipient dissemination or copying of this email is prohibited. If you have received this in error, please notify the sender by replying by email and then delete the email completely from your system. Any views or opinions are solely those of the sender. This communication is not intended to form a binding contract unless expressly indicated to the contrary and properly authorised. Any actions taken on the basis of this email are at the recipient's own risk.
_______________________________________________

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: AuthorizationExecuteWithPrivileges with execution failure error
      • From: John Brownie <email@hidden>
  • Prev by Date: Re: Auto layout and scroll views on OS X
  • Next by Date: Re: AuthorizationExecuteWithPrivileges with execution failure error
  • Previous by thread: CATransaction ignores animationDuration executes completionBlock immediately
  • Next by thread: Re: AuthorizationExecuteWithPrivileges with execution failure error
  • Index(es):
    • Date
    • Thread