diff options
author | Werner Koch <[email protected]> | 2004-04-21 14:42:17 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2004-04-21 14:42:17 +0000 |
commit | 93595de1ede96dedfcaa93c7442536a2cde0b6ef (patch) | |
tree | a0bd56b9a61f7f5301ea2337df1b215bbb318b38 /src/assuan-socket-server.c | |
parent | * assuan-socket-server.c, assuan-socket-connect.c: Includes (diff) | |
download | libassuan-93595de1ede96dedfcaa93c7442536a2cde0b6ef.tar.gz libassuan-93595de1ede96dedfcaa93c7442536a2cde0b6ef.zip |
* assuan-socket-server.c (accept_connection_bottom): Save the pid
of the peer if it is available.
* assuan-socket-connect.c (assuan_socket_connect): Do not save the
dummy SERVED_PID arg.
* assuan-pipe-connect.c (do_finish): Don't wait if the pid is 0.
(assuan_pipe_connect2): Store the parents pid in the environment
of the child.
* assuan-pipe-server.c (assuan_init_pipe_server): Initialize the
peer's pid from the environment.
* assuan-connect.c (assuan_get_pid): Do not return 0 as a PID.
Diffstat (limited to 'src/assuan-socket-server.c')
-rw-r--r-- | src/assuan-socket-server.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/assuan-socket-server.c b/src/assuan-socket-server.c index d92e6e4..e81ee50 100644 --- a/src/assuan-socket-server.c +++ b/src/assuan-socket-server.c @@ -34,14 +34,16 @@ accept_connection_bottom (ASSUAN_CONTEXT ctx) { int fd = ctx->connected_fd; - ctx->client_pid = (pid_t)-1; #ifdef HAVE_SO_PEERCRED { + /* This overrides any already set PID if the function returns a + valid one. */ struct ucred cr; int cl = sizeof cr; - if ( !getsockopt (fd, SOL_SOCKET, SO_PEERCRED, &cr, &cl) ) - ctx->client_pid = cr.pid; + if ( !getsockopt (fd, SOL_SOCKET, SO_PEERCRED, &cr, &cl) + && cr.pid != (pid_t)-1 && cr.pid ) + ctx->pid = cr.pid; } #endif @@ -68,7 +70,6 @@ accept_connection (ASSUAN_CONTEXT ctx) struct sockaddr_un clnt_addr; size_t len = sizeof clnt_addr; - ctx->client_pid = (pid_t)-1; fd = accept (ctx->listen_fd, (struct sockaddr*)&clnt_addr, &len ); if (fd == -1) { |