View | Details | Raw Unified | Return to bug 3290
Collapse All | Expand All

(-)a/ssh.c (-10 / +39 lines)
Lines 1717-1722 control_persist_detach(void) Link Here
1717
		/* muxclient() doesn't return on success. */
1717
		/* muxclient() doesn't return on success. */
1718
		fatal("Failed to connect to new control master");
1718
		fatal("Failed to connect to new control master");
1719
	}
1719
	}
1720
	/* XXX redundant: above fork(), daemon() here and fork_postauth() */
1720
	if (stdfd_devnull(1, 1, !(log_is_on_stderr() && debug_flag)) == -1)
1721
	if (stdfd_devnull(1, 1, !(log_is_on_stderr() && debug_flag)) == -1)
1721
		error_f("stdfd_devnull failed");
1722
		error_f("stdfd_devnull failed");
1722
	daemon(1, 1);
1723
	daemon(1, 1);
Lines 2117-2134 ssh_session2(struct ssh *ssh, const struct ssh_conn_info *cinfo) Link Here
2117
	 * the backgrounding, since we defer attachment of the client until
2118
	 * the backgrounding, since we defer attachment of the client until
2118
	 * after the connection is fully established (in particular,
2119
	 * after the connection is fully established (in particular,
2119
	 * async rfwd replies have been received for ExitOnForwardFailure).
2120
	 * async rfwd replies have been received for ExitOnForwardFailure).
2121
	 *
2122
	 * There are three cases to consider here:
2123
	 * 	1) ssh -oControlPersist=... -N user@host
2124
	 *
2125
	 *      The user does not want forking or command execution. ssh will
2126
	 *      stick around in the foreground until ControlPersist is done.
2127
	 *
2128
	 * 	2) ssh -oControlPersist=... -Nf user@host
2129
	 *
2130
	 *      The user wants a mux-master that runs in the background
2131
	 *      until ControlPersist expires. No command execution. Process
2132
	 *      backgrounding occurs via usual fork_after_authentication_flag.
2133
	 *
2134
	 * 	1) ssh -oControlPersist=... user@host [...]
2135
	 *
2136
	 *	The user wants a session in the foreground (implicitly a
2137
	 *	mux-client) and a mux-master that runs in the background
2138
	 *      until ControlPersist expires. need_controlpersist_detach will
2139
	 *	ensure the mux-master process gets backgrounded and the
2140
	 *      initial process will continue as the mux-client.
2120
	 */
2141
	 */
2121
	if (options.control_persist && muxserver_sock != -1) {
2142
	if (options.control_persist && muxserver_sock != -1) {
2122
		ostdin_null_flag = stdin_null_flag;
2143
		if (no_shell_flag && !fork_after_authentication_flag) {
2123
		ono_shell_flag = no_shell_flag;
2144
			/* case #1 above */
2124
		orequest_tty = options.request_tty;
2145
			stdin_null_flag = 1;
2125
		otty_flag = tty_flag;
2146
			tty_flag = 0;
2126
		stdin_null_flag = 1;
2147
		} else {
2127
		no_shell_flag = 1;
2148
			ostdin_null_flag = stdin_null_flag;
2128
		tty_flag = 0;
2149
			ono_shell_flag = no_shell_flag;
2129
		if (!fork_after_authentication_flag)
2150
			orequest_tty = options.request_tty;
2130
			need_controlpersist_detach = 1;
2151
			otty_flag = tty_flag;
2131
		fork_after_authentication_flag = 1;
2152
			stdin_null_flag = 1;
2153
			no_shell_flag = 1;
2154
			tty_flag = 0;
2155
			if (!fork_after_authentication_flag) {
2156
				/* case #3 above */
2157
				need_controlpersist_detach = 1;
2158
			} /* otherwise case #2 */
2159
			fork_after_authentication_flag = 1;
2160
		}
2132
	}
2161
	}
2133
	/*
2162
	/*
2134
	 * ControlPersist mux listen socket setup failed, attempt the
2163
	 * ControlPersist mux listen socket setup failed, attempt the

Return to bug 3290