5
/* start UNIX-domain file descriptor listener
9
/* int unix_pass_listen(path, backlog, block_mode)
14
/* int unix_pass_accept(fd)
17
/* This module implements a listener that receives one file descriptor
18
/* across each UNIX-domain connection that is made to it.
20
/* unix_pass_listen() creates a listener endpoint with the specified
21
/* permissions, and returns a file descriptor to be used for accepting
24
/* unix_pass_accept() accepts a descriptor.
28
/* Null-terminated string with connection destination.
30
/* This argument exists for compatibility and is ignored.
32
/* Either NON_BLOCKING or BLOCKING. This does not affect the
33
/* mode of accepted connections.
35
/* File descriptor returned by unix_pass_listen().
37
/* Fatal errors: unix_pass_listen() aborts upon any system call failure.
38
/* unix_pass_accept() leaves all error handling up to the caller.
42
/* The Secure Mailer license must be distributed with this software.
45
/* IBM T.J. Watson Research
47
/* Yorktown Heights, NY 10598, USA
53
#include <sys/socket.h>
57
/* Utility library. */
60
#include <sane_accept.h>
63
/* unix_pass_accept - accept descriptor */
65
int unix_pass_accept(int listen_fd)
67
const char *myname = "unix_pass_accept";
71
accept_fd = sane_accept(listen_fd, (struct sockaddr *) 0, (SOCKADDR_SIZE *) 0);
74
msg_warn("%s: accept connection: %m", myname);
77
if (read_wait(accept_fd, 100) < 0)
78
msg_warn("%s: timeout receiving file descriptor: %m", myname);
79
else if ((recv_fd = unix_recv_fd(accept_fd)) < 0)
80
msg_warn("%s: cannot receive file descriptor: %m", myname);
81
if (close(accept_fd) < 0)
82
msg_warn("%s: close: %m", myname);