summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2015-04-24 05:26:44 +0000
committerDamien Miller <djm@mindrot.org>2015-04-29 18:15:38 +1000
commit2ea974630d7017e4c7666d14d9dc939707613e96 (patch)
treef4749aeb88d978a8fd197f606a0dcc7b85be739c
parent8ac2ffd7aa06042f6b924c87139f2fea5c5682f7 (diff)
upstream commit
add ssh-agent -D to leave ssh-agent in foreground without enabling debug mode; bz#2381 ok dtucker@
-rw-r--r--ssh-agent.112
-rw-r--r--ssh-agent.c23
2 files changed, 24 insertions, 11 deletions
diff --git a/ssh-agent.1 b/ssh-agent.1
index 6759afec3..adfb51ccb 100644
--- a/ssh-agent.1
+++ b/ssh-agent.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ssh-agent.1,v 1.57 2014/12/21 22:27:56 djm Exp $ 1.\" $OpenBSD: ssh-agent.1,v 1.58 2015/04/24 05:26:44 djm Exp $
2.\" 2.\"
3.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 3.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -34,7 +34,7 @@
34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36.\" 36.\"
37.Dd $Mdocdate: December 21 2014 $ 37.Dd $Mdocdate: April 24 2015 $
38.Dt SSH-AGENT 1 38.Dt SSH-AGENT 1
39.Os 39.Os
40.Sh NAME 40.Sh NAME
@@ -43,6 +43,7 @@
43.Sh SYNOPSIS 43.Sh SYNOPSIS
44.Nm ssh-agent 44.Nm ssh-agent
45.Op Fl c | s 45.Op Fl c | s
46.Op Fl D
46.Op Fl d 47.Op Fl d
47.Op Fl a Ar bind_address 48.Op Fl a Ar bind_address
48.Op Fl E Ar fingerprint_hash 49.Op Fl E Ar fingerprint_hash
@@ -92,11 +93,16 @@ Generate C-shell commands on
92This is the default if 93This is the default if
93.Ev SHELL 94.Ev SHELL
94looks like it's a csh style of shell. 95looks like it's a csh style of shell.
96.It Fl D
97Foreground mode.
98When this option is specified
99.Nm
100will not fork.
95.It Fl d 101.It Fl d
96Debug mode. 102Debug mode.
97When this option is specified 103When this option is specified
98.Nm 104.Nm
99will not fork. 105will not fork and will write debug information to standard error.
100.It Fl E Ar fingerprint_hash 106.It Fl E Ar fingerprint_hash
101Specifies the hash algorithm used when displaying key fingerprints. 107Specifies the hash algorithm used when displaying key fingerprints.
102Valid options are: 108Valid options are:
diff --git a/ssh-agent.c b/ssh-agent.c
index 2eb3322a0..5356e1161 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-agent.c,v 1.200 2015/04/24 01:36:01 deraadt Exp $ */ 1/* $OpenBSD: ssh-agent.c,v 1.201 2015/04/24 05:26:44 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1146,7 +1146,7 @@ usage(void)
1146int 1146int
1147main(int ac, char **av) 1147main(int ac, char **av)
1148{ 1148{
1149 int c_flag = 0, d_flag = 0, k_flag = 0, s_flag = 0; 1149 int c_flag = 0, d_flag = 0, D_flag = 0, k_flag = 0, s_flag = 0;
1150 int sock, fd, ch, result, saved_errno; 1150 int sock, fd, ch, result, saved_errno;
1151 u_int nalloc; 1151 u_int nalloc;
1152 char *shell, *format, *pidstr, *agentsocket = NULL; 1152 char *shell, *format, *pidstr, *agentsocket = NULL;
@@ -1181,7 +1181,7 @@ main(int ac, char **av)
1181 __progname = ssh_get_progname(av[0]); 1181 __progname = ssh_get_progname(av[0]);
1182 seed_rng(); 1182 seed_rng();
1183 1183
1184 while ((ch = getopt(ac, av, "cdksE:a:t:")) != -1) { 1184 while ((ch = getopt(ac, av, "cDdksE:a:t:")) != -1) {
1185 switch (ch) { 1185 switch (ch) {
1186 case 'E': 1186 case 'E':
1187 fingerprint_hash = ssh_digest_alg_by_name(optarg); 1187 fingerprint_hash = ssh_digest_alg_by_name(optarg);
@@ -1202,10 +1202,15 @@ main(int ac, char **av)
1202 s_flag++; 1202 s_flag++;
1203 break; 1203 break;
1204 case 'd': 1204 case 'd':
1205 if (d_flag) 1205 if (d_flag || D_flag)
1206 usage(); 1206 usage();
1207 d_flag++; 1207 d_flag++;
1208 break; 1208 break;
1209 case 'D':
1210 if (d_flag || D_flag)
1211 usage();
1212 D_flag++;
1213 break;
1209 case 'a': 1214 case 'a':
1210 agentsocket = optarg; 1215 agentsocket = optarg;
1211 break; 1216 break;
@@ -1222,7 +1227,7 @@ main(int ac, char **av)
1222 ac -= optind; 1227 ac -= optind;
1223 av += optind; 1228 av += optind;
1224 1229
1225 if (ac > 0 && (c_flag || k_flag || s_flag || d_flag)) 1230 if (ac > 0 && (c_flag || k_flag || s_flag || d_flag || D_flag))
1226 usage(); 1231 usage();
1227 1232
1228 if (ac == 0 && !c_flag && !s_flag) { 1233 if (ac == 0 && !c_flag && !s_flag) {
@@ -1291,8 +1296,10 @@ main(int ac, char **av)
1291 * Fork, and have the parent execute the command, if any, or present 1296 * Fork, and have the parent execute the command, if any, or present
1292 * the socket data. The child continues as the authentication agent. 1297 * the socket data. The child continues as the authentication agent.
1293 */ 1298 */
1294 if (d_flag) { 1299 if (D_flag || d_flag) {
1295 log_init(__progname, SYSLOG_LEVEL_DEBUG1, SYSLOG_FACILITY_AUTH, 1); 1300 log_init(__progname,
1301 d_flag ? SYSLOG_LEVEL_DEBUG3 : SYSLOG_LEVEL_INFO,
1302 SYSLOG_FACILITY_AUTH, 1);
1296 format = c_flag ? "setenv %s %s;\n" : "%s=%s; export %s;\n"; 1303 format = c_flag ? "setenv %s %s;\n" : "%s=%s; export %s;\n";
1297 printf(format, SSH_AUTHSOCKET_ENV_NAME, socket_name, 1304 printf(format, SSH_AUTHSOCKET_ENV_NAME, socket_name,
1298 SSH_AUTHSOCKET_ENV_NAME); 1305 SSH_AUTHSOCKET_ENV_NAME);
@@ -1364,7 +1371,7 @@ skip:
1364 parent_alive_interval = 10; 1371 parent_alive_interval = 10;
1365 idtab_init(); 1372 idtab_init();
1366 signal(SIGPIPE, SIG_IGN); 1373 signal(SIGPIPE, SIG_IGN);
1367 signal(SIGINT, d_flag ? cleanup_handler : SIG_IGN); 1374 signal(SIGINT, (d_flag | D_flag) ? cleanup_handler : SIG_IGN);
1368 signal(SIGHUP, cleanup_handler); 1375 signal(SIGHUP, cleanup_handler);
1369 signal(SIGTERM, cleanup_handler); 1376 signal(SIGTERM, cleanup_handler);
1370 nalloc = 0; 1377 nalloc = 0;