diff options
Diffstat (limited to 'ssh-agent.c')
-rw-r--r-- | ssh-agent.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/ssh-agent.c b/ssh-agent.c index a0bc9cf09..3b5d06c51 100644 --- a/ssh-agent.c +++ b/ssh-agent.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-agent.c,v 1.80 2002/02/04 00:53:39 stevesk Exp $ */ | 1 | /* $OpenBSD: ssh-agent.c,v 1.81 2002/02/05 15:50:12 stevesk Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -36,7 +36,7 @@ | |||
36 | */ | 36 | */ |
37 | 37 | ||
38 | #include "includes.h" | 38 | #include "includes.h" |
39 | RCSID("$OpenBSD: ssh-agent.c,v 1.80 2002/02/04 00:53:39 stevesk Exp $"); | 39 | RCSID("$OpenBSD: ssh-agent.c,v 1.81 2002/02/05 15:50:12 stevesk Exp $"); |
40 | 40 | ||
41 | #if defined(HAVE_SYS_QUEUE_H) && !defined(HAVE_BOGUS_SYS_QUEUE_H) | 41 | #if defined(HAVE_SYS_QUEUE_H) && !defined(HAVE_BOGUS_SYS_QUEUE_H) |
42 | #include <sys/queue.h> | 42 | #include <sys/queue.h> |
@@ -722,7 +722,8 @@ after_select(fd_set *readset, fd_set *writeset) | |||
722 | sock = accept(sockets[i].fd, | 722 | sock = accept(sockets[i].fd, |
723 | (struct sockaddr *) &sunaddr, &slen); | 723 | (struct sockaddr *) &sunaddr, &slen); |
724 | if (sock < 0) { | 724 | if (sock < 0) { |
725 | perror("accept from AUTH_SOCKET"); | 725 | error("accept from AUTH_SOCKET: %s", |
726 | strerror(errno)); | ||
726 | break; | 727 | break; |
727 | } | 728 | } |
728 | new_socket(AUTH_CONNECTION, sock); | 729 | new_socket(AUTH_CONNECTION, sock); |
@@ -776,7 +777,7 @@ after_select(fd_set *readset, fd_set *writeset) | |||
776 | } | 777 | } |
777 | 778 | ||
778 | static void | 779 | static void |
779 | cleanup_socket(void) | 780 | cleanup_socket(void *p) |
780 | { | 781 | { |
781 | if (socket_name[0]) | 782 | if (socket_name[0]) |
782 | unlink(socket_name); | 783 | unlink(socket_name); |
@@ -787,14 +788,14 @@ cleanup_socket(void) | |||
787 | static void | 788 | static void |
788 | cleanup_exit(int i) | 789 | cleanup_exit(int i) |
789 | { | 790 | { |
790 | cleanup_socket(); | 791 | cleanup_socket(NULL); |
791 | exit(i); | 792 | exit(i); |
792 | } | 793 | } |
793 | 794 | ||
794 | static void | 795 | static void |
795 | cleanup_handler(int sig) | 796 | cleanup_handler(int sig) |
796 | { | 797 | { |
797 | cleanup_socket(); | 798 | cleanup_socket(NULL); |
798 | _exit(2); | 799 | _exit(2); |
799 | } | 800 | } |
800 | 801 | ||
@@ -965,7 +966,7 @@ main(int ac, char **av) | |||
965 | pid = fork(); | 966 | pid = fork(); |
966 | if (pid == -1) { | 967 | if (pid == -1) { |
967 | perror("fork"); | 968 | perror("fork"); |
968 | exit(1); | 969 | cleanup_exit(1); |
969 | } | 970 | } |
970 | if (pid != 0) { /* Parent - execute the given command. */ | 971 | if (pid != 0) { /* Parent - execute the given command. */ |
971 | close(sock); | 972 | close(sock); |
@@ -988,9 +989,11 @@ main(int ac, char **av) | |||
988 | perror(av[0]); | 989 | perror(av[0]); |
989 | exit(1); | 990 | exit(1); |
990 | } | 991 | } |
992 | /* child */ | ||
993 | log_init(__progname, SYSLOG_LEVEL_INFO, SYSLOG_FACILITY_AUTH, 0); | ||
991 | 994 | ||
992 | if (setsid() == -1) { | 995 | if (setsid() == -1) { |
993 | perror("setsid"); | 996 | error("setsid: %s", strerror(errno)); |
994 | cleanup_exit(1); | 997 | cleanup_exit(1); |
995 | } | 998 | } |
996 | 999 | ||
@@ -1003,16 +1006,13 @@ main(int ac, char **av) | |||
1003 | /* deny core dumps, since memory contains unencrypted private keys */ | 1006 | /* deny core dumps, since memory contains unencrypted private keys */ |
1004 | rlim.rlim_cur = rlim.rlim_max = 0; | 1007 | rlim.rlim_cur = rlim.rlim_max = 0; |
1005 | if (setrlimit(RLIMIT_CORE, &rlim) < 0) { | 1008 | if (setrlimit(RLIMIT_CORE, &rlim) < 0) { |
1006 | perror("setrlimit rlimit_core failed"); | 1009 | error("setrlimit RLIMIT_CORE: %s", strerror(errno)); |
1007 | cleanup_exit(1); | 1010 | cleanup_exit(1); |
1008 | } | 1011 | } |
1009 | #endif | 1012 | #endif |
1010 | 1013 | ||
1011 | skip: | 1014 | skip: |
1012 | if (atexit(cleanup_socket) < 0) { | 1015 | fatal_add_cleanup(cleanup_socket, NULL); |
1013 | perror("atexit"); | ||
1014 | cleanup_exit(1); | ||
1015 | } | ||
1016 | new_socket(AUTH_SOCKET, sock); | 1016 | new_socket(AUTH_SOCKET, sock); |
1017 | if (ac > 0) { | 1017 | if (ac > 0) { |
1018 | signal(SIGALRM, check_parent_exists); | 1018 | signal(SIGALRM, check_parent_exists); |
@@ -1031,7 +1031,7 @@ skip: | |||
1031 | if (select(max_fd + 1, readsetp, writesetp, NULL, NULL) < 0) { | 1031 | if (select(max_fd + 1, readsetp, writesetp, NULL, NULL) < 0) { |
1032 | if (errno == EINTR) | 1032 | if (errno == EINTR) |
1033 | continue; | 1033 | continue; |
1034 | exit(1); | 1034 | fatal("select: %s", strerror(errno)); |
1035 | } | 1035 | } |
1036 | after_select(readsetp, writesetp); | 1036 | after_select(readsetp, writesetp); |
1037 | } | 1037 | } |