diff options
author | 2001-06-26 04:07:06 +0000 | |
---|---|---|
committer | 2001-06-26 04:07:06 +0000 | |
commit | a9117a1d200315ce40a790175b68308b752c0d80 (patch) | |
tree | e8cae2b9e4fbbad16dfaca6db166cbe83d9d73d8 | |
parent | sigh (diff) | |
download | wireguard-openbsd-a9117a1d200315ce40a790175b68308b752c0d80.tar.xz wireguard-openbsd-a9117a1d200315ce40a790175b68308b752c0d80.zip |
add debug flag
-rw-r--r-- | usr.bin/ssh/ssh-agent.1 | 8 | ||||
-rw-r--r-- | usr.bin/ssh/ssh-agent.c | 33 |
2 files changed, 32 insertions, 9 deletions
diff --git a/usr.bin/ssh/ssh-agent.1 b/usr.bin/ssh/ssh-agent.1 index 1d214698d72..0aecfc0f062 100644 --- a/usr.bin/ssh/ssh-agent.1 +++ b/usr.bin/ssh/ssh-agent.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ssh-agent.1,v 1.24 2001/04/10 09:13:21 itojun Exp $ +.\" $OpenBSD: ssh-agent.1,v 1.25 2001/06/26 04:07:06 markus Exp $ .\" .\" Author: Tatu Ylonen <ylo@cs.hut.fi> .\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -48,6 +48,8 @@ .Op Fl c Li | Fl s .Nm ssh-agent .Fl k +.Nm ssh-agent +.Fl d .Sh DESCRIPTION .Nm is a program to hold private keys used for public key authentication @@ -80,6 +82,10 @@ does not look like it's a csh style of shell. Kill the current agent (given by the .Ev SSH_AGENT_PID environment variable). +.It Fl d +Debug mode. When this option is specified +.Nm +will fork. .El .Pp If a commandline is given, this is executed as a subprocess of the agent. diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c index e6546110eb4..2fa6565b152 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.56 2001/06/25 08:25:40 markus Exp $ */ +/* $OpenBSD: ssh-agent.c,v 1.57 2001/06/26 04:07:06 markus Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> @@ -36,7 +36,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh-agent.c,v 1.56 2001/06/25 08:25:40 markus Exp $"); +RCSID("$OpenBSD: ssh-agent.c,v 1.57 2001/06/26 04:07:06 markus Exp $"); #include <openssl/evp.h> #include <openssl/md5.h> @@ -702,7 +702,7 @@ usage(void) int main(int ac, char **av) { - int sock, c_flag = 0, k_flag = 0, s_flag = 0, ch; + int sock, c_flag = 0, d_flag = 0, k_flag = 0, s_flag = 0, ch; struct sockaddr_un sunaddr; struct rlimit rlim; pid_t pid; @@ -712,7 +712,7 @@ main(int ac, char **av) SSLeay_add_all_algorithms(); - while ((ch = getopt(ac, av, "cks")) != -1) { + while ((ch = getopt(ac, av, "cdks")) != -1) { switch (ch) { case 'c': if (s_flag) @@ -727,6 +727,11 @@ main(int ac, char **av) usage(); s_flag++; break; + case 'd': + if (d_flag) + usage(); + d_flag++; + break; default: usage(); } @@ -734,10 +739,10 @@ main(int ac, char **av) ac -= optind; av += optind; - if (ac > 0 && (c_flag || k_flag || s_flag)) + if (ac > 0 && (c_flag || k_flag || s_flag || d_flag)) usage(); - if (ac == 0 && !c_flag && !k_flag && !s_flag) { + if (ac == 0 && !c_flag && !k_flag && !s_flag && !d_flag) { shell = getenv("SHELL"); if (shell != NULL && strncmp(shell + strlen(shell) - 3, "csh", 3) == 0) c_flag = 1; @@ -801,6 +806,14 @@ main(int ac, char **av) * Fork, and have the parent execute the command, if any, or present * the socket data. The child continues as the authentication agent. */ + if (d_flag) { + log_init(__progname, SYSLOG_LEVEL_DEBUG1, SYSLOG_FACILITY_AUTH, 1); + format = c_flag ? "setenv %s %s;\n" : "%s=%s; export %s;\n"; + printf(format, SSH_AUTHSOCKET_ENV_NAME, socket_name, + SSH_AUTHSOCKET_ENV_NAME); + printf("echo Agent pid %d;\n", parent_pid); + goto skip; + } pid = fork(); if (pid == -1) { perror("fork"); @@ -841,6 +854,8 @@ main(int ac, char **av) perror("setsid"); cleanup_exit(1); } + +skip: if (atexit(cleanup_socket) < 0) { perror("atexit"); cleanup_exit(1); @@ -851,8 +866,10 @@ main(int ac, char **av) alarm(10); } idtab_init(); - signal(SIGINT, SIG_IGN); - signal(SIGPIPE, SIG_IGN); + if (!d_flag) { + signal(SIGINT, SIG_IGN); + signal(SIGPIPE, SIG_IGN); + } signal(SIGHUP, cleanup_handler); signal(SIGTERM, cleanup_handler); while (1) { |