-#ifdef __APPLE__
- /* We need to use authopen to open the device. It asks the user for permission
- * then give us an open fd over a socket.
- */
-
- int pipe[2];
- if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipe) < 0) {
- return EFAULT;
- }
-
- pid_t pid = fork();
- if (pid < 0) {
- return EFAULT;
- }
-
- if (pid == 0) {
- close(pipe[0]);
- dup2(pipe[1], STDOUT_FILENO);
- execl("/usr/libexec/authopen", "/usr/libexec/authopen", "-stdoutpipe", "-w", "-a", fname, (char *) 0);
- exit(-1);
- }
-
- close(pipe[1]);
-
- int dev = -1;
-
- size_t const data_buffer_size = sizeof(struct cmsghdr) + sizeof(int);
- char data_buffer[data_buffer_size];
-
- struct iovec io_vec[1];
- io_vec[0].iov_base = data_buffer;
- io_vec[0].iov_len = data_buffer_size;
-
- socklen_t const cmsg_socket_size = CMSG_SPACE(sizeof(int));
- char cmsg_socket[cmsg_socket_size];
- struct msghdr message = { 0 };
- message.msg_iov = io_vec;
- message.msg_iovlen = 1;
- message.msg_control = cmsg_socket;
- message.msg_controllen = cmsg_socket_size;