diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2021-07-23 04:04:53 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2021-07-23 04:04:53 +0000 |
commit | 451c355109e344aeee9cb60c47c3bc4ad3652ce0 (patch) | |
tree | 3fbbcbe01adeca37bc9e92dc74b8be451b9ffbb0 /usr.bin/ssh/ssh.c | |
parent | 23381a9697df632d79117ebf9aa503cb7ea0537d (diff) |
Add a ForkAfterAuthentication ssh_config(5) counterpart to the
ssh(1) -f flag. Last part of GHPR231 from Volker Diels-Grabsch.
ok dtucker
Diffstat (limited to 'usr.bin/ssh/ssh.c')
-rw-r--r-- | usr.bin/ssh/ssh.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c index 0b86ab881f4..5b577b6fef5 100644 --- a/usr.bin/ssh/ssh.c +++ b/usr.bin/ssh/ssh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh.c,v 1.563 2021/07/23 04:00:59 djm Exp $ */ +/* $OpenBSD: ssh.c,v 1.564 2021/07/23 04:04:52 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -120,13 +120,6 @@ int need_controlpersist_detach = 0; int ostdin_null_flag, osession_type, otty_flag, orequest_tty; /* - * Flag indicating that ssh should fork after authentication. This is useful - * so that the passphrase can be entered manually, and then ssh goes to the - * background. - */ -int fork_after_authentication_flag = 0; - -/* * General data structure for command line options and options configurable * in configuration files. See readconf.h. */ @@ -694,7 +687,7 @@ main(int ac, char **av) options.stdin_null = 1; break; case 'f': - fork_after_authentication_flag = 1; + options.fork_after_authentication = 1; options.stdin_null = 1; break; case 'x': @@ -1303,7 +1296,7 @@ main(int ac, char **av) fatal("Cannot execute command-line and remote command."); /* Cannot fork to background if no command. */ - if (fork_after_authentication_flag && sshbuf_len(command) == 0 && + if (options.fork_after_authentication && sshbuf_len(command) == 0 && options.remote_command == NULL && options.session_type != SESSION_TYPE_NONE) fatal("Cannot fork into background without a command " @@ -1731,7 +1724,7 @@ fork_postauth(void) if (need_controlpersist_detach) control_persist_detach(); debug("forking to background"); - fork_after_authentication_flag = 0; + options.fork_after_authentication = 0; if (daemon(1, 1) == -1) fatal("daemon() failed: %.200s", strerror(errno)); if (stdfd_devnull(1, 1, !(log_is_on_stderr() && debug_flag)) == -1) @@ -1745,7 +1738,7 @@ forwarding_success(void) return; if (--forward_confirms_pending == 0) { debug_f("all expected forwarding replies received"); - if (fork_after_authentication_flag) + if (options.fork_after_authentication) fork_postauth(); } else { debug2_f("%d expected forwarding replies remaining", @@ -2124,11 +2117,11 @@ ssh_session2(struct ssh *ssh, const struct ssh_conn_info *cinfo) options.stdin_null = 1; options.session_type = SESSION_TYPE_NONE; tty_flag = 0; - if (!fork_after_authentication_flag && + if (!options.fork_after_authentication && (osession_type != SESSION_TYPE_NONE || options.stdio_forward_host != NULL)) need_controlpersist_detach = 1; - fork_after_authentication_flag = 1; + options.fork_after_authentication = 1; } /* * ControlPersist mux listen socket setup failed, attempt the @@ -2175,7 +2168,7 @@ ssh_session2(struct ssh *ssh, const struct ssh_conn_info *cinfo) * If requested and we are not interested in replies to remote * forwarding requests, then let ssh continue in the background. */ - if (fork_after_authentication_flag) { + if (options.fork_after_authentication) { if (options.exit_on_forward_failure && options.num_remote_forwards > 0) { debug("deferring postauth fork until remote forward " |