diff options
author | Damien Miller <djm@mindrot.org> | 2013-04-23 15:21:06 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2013-04-23 15:21:06 +1000 |
commit | 03d4d7e60b16f913c75382e32e136ddfa8d6485f (patch) | |
tree | 56db601b0ddcd36e27c565ce0e127330ac2de381 /ssh.c | |
parent | 37f1c08473b1ef2a188ee178ce2e11e841f88563 (diff) |
- dtucker@cvs.openbsd.org 2013/04/07 02:10:33
[log.c log.h ssh.1 ssh.c sshd.8 sshd.c]
Add -E option to ssh and sshd to append debugging logs to a specified file
instead of stderr or syslog. ok markus@, man page help jmc@
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 28 |
1 files changed, 20 insertions, 8 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.374 2013/03/08 06:32:58 djm Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.375 2013/04/07 02:10:33 dtucker 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 |
@@ -197,8 +197,8 @@ usage(void) | |||
197 | { | 197 | { |
198 | fprintf(stderr, | 198 | fprintf(stderr, |
199 | "usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]\n" | 199 | "usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]\n" |
200 | " [-D [bind_address:]port] [-e escape_char] [-F configfile]\n" | 200 | " [-D [bind_address:]port] [-E log_file] [-e escape_char]\n" |
201 | " [-I pkcs11] [-i identity_file]\n" | 201 | " [-F configfile] [-I pkcs11] [-i identity_file]\n" |
202 | " [-L [bind_address:]port:host:hostport]\n" | 202 | " [-L [bind_address:]port:host:hostport]\n" |
203 | " [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]\n" | 203 | " [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]\n" |
204 | " [-R [bind_address:]port:host:hostport] [-S ctl_path]\n" | 204 | " [-R [bind_address:]port:host:hostport] [-S ctl_path]\n" |
@@ -238,7 +238,7 @@ int | |||
238 | main(int ac, char **av) | 238 | main(int ac, char **av) |
239 | { | 239 | { |
240 | int i, r, opt, exit_status, use_syslog; | 240 | int i, r, opt, exit_status, use_syslog; |
241 | char *p, *cp, *line, *argv0, buf[MAXPATHLEN], *host_arg; | 241 | char *p, *cp, *line, *argv0, buf[MAXPATHLEN], *host_arg, *logfile; |
242 | char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; | 242 | char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; |
243 | struct stat st; | 243 | struct stat st; |
244 | struct passwd *pw; | 244 | struct passwd *pw; |
@@ -322,11 +322,12 @@ main(int ac, char **av) | |||
322 | /* Parse command-line arguments. */ | 322 | /* Parse command-line arguments. */ |
323 | host = NULL; | 323 | host = NULL; |
324 | use_syslog = 0; | 324 | use_syslog = 0; |
325 | logfile = NULL; | ||
325 | argv0 = av[0]; | 326 | argv0 = av[0]; |
326 | 327 | ||
327 | again: | 328 | again: |
328 | while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvx" | 329 | while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvx" |
329 | "ACD:F:I:KL:MNO:PR:S:TVw:W:XYy")) != -1) { | 330 | "ACD:E:F:I:KL:MNO:PR:S:TVw:W:XYy")) != -1) { |
330 | switch (opt) { | 331 | switch (opt) { |
331 | case '1': | 332 | case '1': |
332 | options.protocol = SSH_PROTO_1; | 333 | options.protocol = SSH_PROTO_1; |
@@ -356,6 +357,9 @@ main(int ac, char **av) | |||
356 | case 'y': | 357 | case 'y': |
357 | use_syslog = 1; | 358 | use_syslog = 1; |
358 | break; | 359 | break; |
360 | case 'E': | ||
361 | logfile = xstrdup(optarg); | ||
362 | break; | ||
359 | case 'Y': | 363 | case 'Y': |
360 | options.forward_x11 = 1; | 364 | options.forward_x11 = 1; |
361 | options.forward_x11_trusted = 1; | 365 | options.forward_x11_trusted = 1; |
@@ -427,9 +431,8 @@ main(int ac, char **av) | |||
427 | } else { | 431 | } else { |
428 | if (options.log_level < SYSLOG_LEVEL_DEBUG3) | 432 | if (options.log_level < SYSLOG_LEVEL_DEBUG3) |
429 | options.log_level++; | 433 | options.log_level++; |
430 | break; | ||
431 | } | 434 | } |
432 | /* FALLTHROUGH */ | 435 | break; |
433 | case 'V': | 436 | case 'V': |
434 | fprintf(stderr, "%s, %s\n", | 437 | fprintf(stderr, "%s, %s\n", |
435 | SSH_RELEASE, SSLeay_version(SSLEAY_VERSION)); | 438 | SSH_RELEASE, SSLeay_version(SSLEAY_VERSION)); |
@@ -663,12 +666,21 @@ main(int ac, char **av) | |||
663 | 666 | ||
664 | /* | 667 | /* |
665 | * Initialize "log" output. Since we are the client all output | 668 | * Initialize "log" output. Since we are the client all output |
666 | * actually goes to stderr. | 669 | * goes to stderr unless otherwise specified by -y or -E. |
667 | */ | 670 | */ |
671 | if (use_syslog && logfile != NULL) | ||
672 | fatal("Can't specify both -y and -E"); | ||
673 | if (logfile != NULL) { | ||
674 | log_redirect_stderr_to(logfile); | ||
675 | xfree(logfile); | ||
676 | } | ||
668 | log_init(argv0, | 677 | log_init(argv0, |
669 | options.log_level == -1 ? SYSLOG_LEVEL_INFO : options.log_level, | 678 | options.log_level == -1 ? SYSLOG_LEVEL_INFO : options.log_level, |
670 | SYSLOG_FACILITY_USER, !use_syslog); | 679 | SYSLOG_FACILITY_USER, !use_syslog); |
671 | 680 | ||
681 | if (debug_flag) | ||
682 | logit("%s, %s", SSH_VERSION, SSLeay_version(SSLEAY_VERSION)); | ||
683 | |||
672 | /* | 684 | /* |
673 | * Read per-user configuration file. Ignore the system wide config | 685 | * Read per-user configuration file. Ignore the system wide config |
674 | * file if the user specifies a config file on the command line. | 686 | * file if the user specifies a config file on the command line. |