summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@cvs.openbsd.org>2011-06-03 01:37:41 +0000
committerDarren Tucker <dtucker@cvs.openbsd.org>2011-06-03 01:37:41 +0000
commit0f418b6c6d02e1cc01d85e98f6e7924cbdb01d8c (patch)
tree5dacb35d46536ee318cb391856cbc3acaf7247dd
parent16f5f2e7b5a70d3ae10f81f25a471549deeba146 (diff)
Check current parent process ID against saved one to determine if the parent
has exited, rather than attempting to send a zero signal, since the latter won't work if the parent has changed privs. bz#1905, patch from Daniel Kahn Gillmor, ok djm@
-rw-r--r--usr.bin/ssh/ssh-agent.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c
index 4768c9c3cc2..ca962f1094b 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.171 2010/11/21 01:01:13 djm Exp $ */
+/* $OpenBSD: ssh-agent.c,v 1.172 2011/06/03 01:37:40 dtucker Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1076,7 +1076,11 @@ cleanup_handler(int sig)
static void
check_parent_exists(void)
{
- if (parent_pid != -1 && kill(parent_pid, 0) < 0) {
+ /*
+ * If our parent has exited then getppid() will return (pid_t)1,
+ * so testing for that should be safe.
+ */
+ if (parent_pid != -1 && getppid() != parent_pid) {
/* printf("Parent has died - Authentication agent exiting.\n"); */
cleanup_socket();
_exit(2);