• 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 flag error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AuthorizationExecuteWithPrivileges flag error


  • Subject: AuthorizationExecuteWithPrivileges flag error
  • From: sheen mac <email@hidden>
  • Date: Wed, 30 Jul 2008 06:16:53 -0700 (PDT)

Hi All,

In my project , I added an executable and created AuthorizationRef
successfully.The AuthorizationCopyRights also worked without
error.But when AuthorizationExecuteWithPrivileges , it shows
the invalid flags error.

Kindly help me.

Thanks In Advance,
Sheen

 OSStatus status;AuthorizationRef auth;
AuthorizationExternalForm extAuth;


	if (geteuid() != 0) {
		setuid(0);
	}

	if (fread(&extAuth, sizeof(extAuth), 1, stdin) != 1)
		exit(-1);
	if (AuthorizationCreateFromExternalForm(&extAuth, &auth))
		exit(-1);


	AuthorizationItem right = { RIGHT, 0, NULL, 0 };
	AuthorizationRights rights = { 1, &right };
	AuthorizationFlags flags = kAuthorizationFlagDefaults | kAuthorizationFlagExtendRights;


	if (status = AuthorizationCopyRights(auth, &rights, kAuthorizationEmptyEnvironment, flags, NULL)) {
		exit(-1);
	}

char* args[3];
    OSStatus err = 0;
    FILE* iopipe;


    args[0] = "-w";
    args[1]="net.inet.ip.forwarding=1";
    args[2]=NULL;

    err = AuthorizationExecuteWithPrivileges(auth,
                                             "/usr/sbin/sysctl",
                                             flags, args, &iopipe);


	if(err!=errAuthorizationSuccess)
		fprintf(stderr,"failed\n");





_______________________________________________

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

  • Prev by Date: Two different actions depending on the event when clicking a NSStatusItem?
  • Next by Date: Re: Two different actions depending on the event when clicking a NSStatusItem?
  • Previous by thread: Re: Two different actions depending on the event when clicking a NSStatusItem?
  • Next by thread: [meeting] CocoaHeads Swindon, Monday August 4th
  • Index(es):
    • Date
    • Thread