title: AuthorizationExecuteWithPrivileges() as root Error
body: <p>I am a beginner in cocoa...</p>
  
  <p>I just want to start Apache and other process in my Cocoa App.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>    OSStatus myStatus;
      AuthorizationFlags myFlags = kAuthorizationFlagDefaults;
      AuthorizationRef myAuthorizationRef;
      FILE *pipe = NULL;
      myStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, myFlags, &amp;myAuthorizationRef);
      AuthorizationItem myItems = {kAuthorizationRightExecute, 0, NULL, 0};
      AuthorizationRights myRights = {1, &amp;myItems};
      myFlags = kAuthorizationFlagDefaults | 
      kAuthorizationFlagInteractionAllowed |
      kAuthorizationFlagPreAuthorize |
      kAuthorizationFlagExtendRights;
      myStatus = AuthorizationCopyPrivilegedReference (&amp;myAuthorizationRef,kAuthorizationFlagDefaults);
      myStatus = AuthorizationCopyRights (myAuthorizationRef,&amp;myRights, NULL, myFlags, NULL ); 
  
      char *tool = "/usr/sbin/apachectl";
      char *args[] = { "start",NULL} ;    
  
      myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef, tool, kAuthorizationFlagDefaults, args, &amp;pipe);
      char c[100];
      int n=fread(c,1,100,pipe);
      c[n] = '\0';
      NSLog(@"%s\n",c);
  </code></pre>
  
  <p>theResult :  <strong><em>This operation requires root</em></strong><br>When I run a <strong>'whoami'</strong>, I'm '<strong>root'</strong> but when I run a <strong>getuid()</strong>, I'm '<strong>501'</strong>...</p>
  
  <p>I try to use setuid(0); But it doesn't set !!<br>
  Can you help me? <br> Thanks</p>