]> andersk Git - openssh.git/blobdiff - ssh-agent.c
- (djm) OpenBSD CVS Sync:
[openssh.git] / ssh-agent.c
index bc577e76a93ef72deb51c8b4a693428f4f0400c1..539f8ce7d58fbaaf5a6e08ad4086dfc0670a7129 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ssh-agent.c,v 1.47 2001/01/21 19:05:56 markus Exp $   */
+/*     $OpenBSD: ssh-agent.c,v 1.48 2001/01/25 08:06:33 deraadt Exp $  */
 
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -37,7 +37,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: ssh-agent.c,v 1.47 2001/01/21 19:05:56 markus Exp $");
+RCSID("$OpenBSD: ssh-agent.c,v 1.48 2001/01/25 08:06:33 deraadt Exp $");
 
 #include <openssl/evp.h>
 #include <openssl/md5.h>
@@ -683,8 +683,10 @@ check_parent_exists(int sig)
 void
 cleanup_socket(void)
 {
-       unlink(socket_name);
-       rmdir(socket_dir);
+       if (socket_name[0])
+               unlink(socket_name);
+       if (socket_dir[0])
+               rmdir(socket_dir);
 }
 
 void
@@ -694,12 +696,19 @@ cleanup_exit(int i)
        exit(i);
 }
 
+void
+cleanup_handler(int sig)
+{
+       cleanup_socket();
+       _exit(2);
+}
+
 void
 usage()
 {
        fprintf(stderr, "ssh-agent version %s\n", SSH_VERSION);
        fprintf(stderr, "Usage: %s [-c | -s] [-k] [command {args...]]\n",
-            __progname);
+           __progname);
        exit(1);
 }
 
@@ -866,8 +875,8 @@ main(int ac, char **av)
        idtab_init();
        signal(SIGINT, SIG_IGN);
        signal(SIGPIPE, SIG_IGN);
-       signal(SIGHUP, cleanup_exit);
-       signal(SIGTERM, cleanup_exit);
+       signal(SIGHUP, cleanup_handler);
+       signal(SIGTERM, cleanup_handler);
        while (1) {
                prepare_select(&readsetp, &writesetp, &max_fd);
                if (select(max_fd + 1, readsetp, writesetp, NULL, NULL) < 0) {
This page took 0.038929 seconds and 4 git commands to generate.