summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2014-07-03 03:11:04 +0000
committerDamien Miller <djm@cvs.openbsd.org>2014-07-03 03:11:04 +0000
commitf9c481c6b2597d3df857a63bebdf5636e73279d2 (patch)
tree807be3d0ac6de5ade219f7fb5bb6263e2627fe6b /usr.bin
parent5d41488e530212bc1fd484a9baab7290dfc0de06 (diff)
Only cleanup agent socket in the main agent process and not in any
subprocesses it may have started (e.g. forked askpass). Fixes agent sockets being zapped when askpass processes fatal(); bz#2236 patch from Dmitry V. Levin
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/ssh-agent.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c
index 963c0cdace7..4c0b6184a6c 100644
--- a/usr.bin/ssh/ssh-agent.c
+++ b/usr.bin/ssh/ssh-agent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-agent.c,v 1.186 2014/06/24 01:13:21 djm Exp $ */
+/* $OpenBSD: ssh-agent.c,v 1.187 2014/07/03 03:11:03 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -112,6 +112,9 @@ int max_fd = 0;
pid_t parent_pid = -1;
time_t parent_alive_interval = 0;
+/* pid of process for which cleanup_socket is applicable */
+pid_t cleanup_pid = 0;
+
/* pathname and directory for AUTH_SOCKET */
char socket_name[MAXPATHLEN];
char socket_dir[MAXPATHLEN];
@@ -960,6 +963,9 @@ after_select(fd_set *readset, fd_set *writeset)
static void
cleanup_socket(void)
{
+ if (cleanup_pid != 0 && getpid() != cleanup_pid)
+ return;
+ debug("%s: cleanup", __func__);
if (socket_name[0])
unlink(socket_name);
if (socket_dir[0])
@@ -1212,6 +1218,8 @@ main(int ac, char **av)
skip:
+ cleanup_pid = getpid();
+
#ifdef ENABLE_PKCS11
pkcs11_init(0);
#endif