From 5ba29faa04960f19c0c3ff005c2b897c3094c1d6 Mon Sep 17 00:00:00 2001 From: des Date: Thu, 27 Jun 2002 22:42:11 +0000 Subject: Forcibly revert to mainline. --- crypto/openssh/ssh-agent.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'crypto/openssh/ssh-agent.c') diff --git a/crypto/openssh/ssh-agent.c b/crypto/openssh/ssh-agent.c index 4fc0f23..c3a9077 100644 --- a/crypto/openssh/ssh-agent.c +++ b/crypto/openssh/ssh-agent.c @@ -34,9 +34,8 @@ */ #include "includes.h" -#include +#include "openbsd-compat/fake-queue.h" RCSID("$OpenBSD: ssh-agent.c,v 1.95 2002/06/19 00:27:55 deraadt Exp $"); -RCSID("$FreeBSD$"); #include #include @@ -101,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) @@ -926,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; @@ -935,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) @@ -1025,11 +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)); - sunaddr.sun_len = SUN_LEN(&sunaddr) + 1; - if (bind(sock, (struct sockaddr *)&sunaddr, sunaddr.sun_len) < 0) { +#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); @@ -1086,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); -- cgit v1.1