diff options
Diffstat (limited to 'crypto/openssh/ssh-agent.c')
-rw-r--r-- | crypto/openssh/ssh-agent.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/crypto/openssh/ssh-agent.c b/crypto/openssh/ssh-agent.c index 84f75fd..c3a9077 100644 --- a/crypto/openssh/ssh-agent.c +++ b/crypto/openssh/ssh-agent.c @@ -34,7 +34,7 @@ */ #include "includes.h" -#include <sys/queue.h> +#include "openbsd-compat/fake-queue.h" RCSID("$OpenBSD: ssh-agent.c,v 1.95 2002/06/19 00:27:55 deraadt Exp $"); #include <openssl/evp.h> @@ -100,7 +100,11 @@ char socket_dir[1024]; int locked = 0; char *lock_passwd = NULL; +#ifdef HAVE___PROGNAME extern char *__progname; +#else +char *__progname; +#endif static void idtab_init(void) @@ -925,7 +929,12 @@ main(int ac, char **av) { int sock, c_flag = 0, d_flag = 0, k_flag = 0, s_flag = 0, ch, nalloc; struct sockaddr_un sunaddr; +#ifdef HAVE_SETRLIMIT struct rlimit rlim; +#endif +#ifdef HAVE_CYGWIN + int prev_mask; +#endif pid_t pid; char *shell, *format, *pidstr, pidstrbuf[1 + 3 * sizeof pid]; char *agentsocket = NULL; @@ -934,7 +943,15 @@ main(int ac, char **av) SSLeay_add_all_algorithms(); + __progname = get_progname(av[0]); + init_rng(); + seed_rng(); + +#ifdef __GNU_LIBRARY__ + while ((ch = getopt(ac, av, "+cdksa:")) != -1) { +#else /* __GNU_LIBRARY__ */ while ((ch = getopt(ac, av, "cdksa:")) != -1) { +#endif /* __GNU_LIBRARY__ */ switch (ch) { case 'c': if (s_flag) @@ -1024,10 +1041,19 @@ main(int ac, char **av) memset(&sunaddr, 0, sizeof(sunaddr)); sunaddr.sun_family = AF_UNIX; strlcpy(sunaddr.sun_path, socket_name, sizeof(sunaddr.sun_path)); +#ifdef HAVE_CYGWIN + prev_mask = umask(0177); +#endif if (bind(sock, (struct sockaddr *) & sunaddr, sizeof(sunaddr)) < 0) { perror("bind"); +#ifdef HAVE_CYGWIN + umask(prev_mask); +#endif cleanup_exit(1); } +#ifdef HAVE_CYGWIN + umask(prev_mask); +#endif if (listen(sock, 5) < 0) { perror("listen"); cleanup_exit(1); @@ -1084,12 +1110,14 @@ main(int ac, char **av) close(1); close(2); +#ifdef HAVE_SETRLIMIT /* deny core dumps, since memory contains unencrypted private keys */ rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { error("setrlimit RLIMIT_CORE: %s", strerror(errno)); cleanup_exit(1); } +#endif skip: fatal_add_cleanup(cleanup_socket, NULL); |