title: How can I pre-authorize authopen?
body: <p>I'm using <code>authopen</code> inside one of my programs to modify files owned by root. As can be seen in the screenshot below <code>authopen</code> asks for a admin password. What I'd like to achieve is that the dialog shows my app's name and then passes the authorization to <code>authopen</code>.</p>
  
  <p><img src="https://i.stack.imgur.com/G7T2X.png" alt="authopen requires that you type your password."></p>
  
  <h2>Code</h2>
  
  <p>Launching <code>authopen</code> which returns an authorized file descriptor.</p>
  
  <pre class="lang-objc prettyprint-override"><code>int pipe[2];
  
  socketpair(AF_UNIX, SOCK_STREAM, 0, pipe);
  
  if (fork() == 0) {      // child
      // close parent's pipe
      close(pipe[0]);
      dup2(pipe[1], STDOUT_FILENO);
  
      const char *authopenPath = "/usr/libexec/authopen";
      execl(authopenPath,
            authopenPath,
            "-stdoutpipe",
            [self.device.devicePath fileSystemRepresentation],
            NULL);
  
      NSLog(@"Fatal error, we should never reach %s:%d", __FILE__, __LINE__);
      exit(-1);
  } else { // parent
      close(pipe[1]);
  }
  
  // get file descriptor through sockets
  </code></pre>
  
  <p>I'd really like <em>not</em> to use <code>AuthorizationExecuteWithPrivileges</code> because then I'd have to get more rights than I want to.</p>