version 1.559, 2021/06/08 07:07:15 |
version 1.560, 2021/07/13 23:48:36 |
|
|
/* Flag indicating whether a tty should be requested */ |
/* Flag indicating whether a tty should be requested */ |
int tty_flag = 0; |
int tty_flag = 0; |
|
|
/* don't exec a shell */ |
|
int no_shell_flag = 0; |
|
|
|
/* |
/* |
* Flag indicating that nothing should be read from stdin. This can be set |
* Flag indicating that nothing should be read from stdin. This can be set |
* on the command line. |
* on the command line. |
|
|
int need_controlpersist_detach = 0; |
int need_controlpersist_detach = 0; |
|
|
/* Copies of flags for ControlPersist foreground mux-client */ |
/* Copies of flags for ControlPersist foreground mux-client */ |
int ostdin_null_flag, ono_shell_flag, otty_flag, orequest_tty; |
int ostdin_null_flag, osession_type, otty_flag, orequest_tty; |
|
|
/* |
/* |
* Flag indicating that ssh should fork after authentication. This is useful |
* Flag indicating that ssh should fork after authentication. This is useful |
|
|
/* command to be executed */ |
/* command to be executed */ |
struct sshbuf *command; |
struct sshbuf *command; |
|
|
/* Should we execute a command or invoke a subsystem? */ |
|
int subsystem_flag = 0; |
|
|
|
/* # of replies received for global requests */ |
/* # of replies received for global requests */ |
static int forward_confirms_pending = -1; |
static int forward_confirms_pending = -1; |
|
|
|
|
exit(255); |
exit(255); |
} |
} |
options.request_tty = REQUEST_TTY_NO; |
options.request_tty = REQUEST_TTY_NO; |
no_shell_flag = 1; |
options.session_type = SESSION_TYPE_NONE; |
break; |
break; |
case 'q': |
case 'q': |
options.log_level = SYSLOG_LEVEL_QUIET; |
options.log_level = SYSLOG_LEVEL_QUIET; |
|
|
#endif |
#endif |
break; |
break; |
case 'N': |
case 'N': |
no_shell_flag = 1; |
if (options.session_type != -1 && |
|
options.session_type != SESSION_TYPE_NONE) |
|
fatal("Cannot specify -N with -s/SessionType"); |
|
options.session_type = SESSION_TYPE_NONE; |
options.request_tty = REQUEST_TTY_NO; |
options.request_tty = REQUEST_TTY_NO; |
break; |
break; |
case 'T': |
case 'T': |
|
|
free(line); |
free(line); |
break; |
break; |
case 's': |
case 's': |
subsystem_flag = 1; |
if (options.session_type != -1 && |
|
options.session_type != SESSION_TYPE_SUBSYSTEM) |
|
fatal("Cannot specify -s with -N/SessionType"); |
|
options.session_type = SESSION_TYPE_SUBSYSTEM; |
break; |
break; |
case 'S': |
case 'S': |
free(options.control_path); |
free(options.control_path); |
|
|
*/ |
*/ |
if (!ac) { |
if (!ac) { |
/* No command specified - execute shell on a tty. */ |
/* No command specified - execute shell on a tty. */ |
if (subsystem_flag) { |
if (options.session_type == SESSION_TYPE_SUBSYSTEM) { |
fprintf(stderr, |
fprintf(stderr, |
"You must specify a subsystem to invoke.\n"); |
"You must specify a subsystem to invoke.\n"); |
usage(); |
usage(); |
|
|
|
|
/* Cannot fork to background if no command. */ |
/* Cannot fork to background if no command. */ |
if (fork_after_authentication_flag && sshbuf_len(command) == 0 && |
if (fork_after_authentication_flag && sshbuf_len(command) == 0 && |
options.remote_command == NULL && !no_shell_flag) |
options.remote_command == NULL && options.session_type != SESSION_TYPE_NONE) |
fatal("Cannot fork into background without a command " |
fatal("Cannot fork into background without a command " |
"to execute."); |
"to execute."); |
|
|
|
|
if ((term = lookup_env_in_list("TERM", options.setenv, |
if ((term = lookup_env_in_list("TERM", options.setenv, |
options.num_setenv)) == NULL || *term == '\0') |
options.num_setenv)) == NULL || *term == '\0') |
term = getenv("TERM"); |
term = getenv("TERM"); |
client_session2_setup(ssh, id, tty_flag, subsystem_flag, term, |
client_session2_setup(ssh, id, tty_flag, options.session_type == SESSION_TYPE_SUBSYSTEM, term, |
NULL, fileno(stdin), command, environ); |
NULL, fileno(stdin), command, environ); |
} |
} |
|
|
|
|
debug3_f("channel_new: %d", c->self); |
debug3_f("channel_new: %d", c->self); |
|
|
channel_send_open(ssh, c->self); |
channel_send_open(ssh, c->self); |
if (!no_shell_flag) |
if (options.session_type != SESSION_TYPE_NONE) |
channel_register_open_confirm(ssh, c->self, |
channel_register_open_confirm(ssh, c->self, |
ssh_session2_setup, NULL); |
ssh_session2_setup, NULL); |
|
|
|
|
*/ |
*/ |
if (options.control_persist && muxserver_sock != -1) { |
if (options.control_persist && muxserver_sock != -1) { |
ostdin_null_flag = stdin_null_flag; |
ostdin_null_flag = stdin_null_flag; |
ono_shell_flag = no_shell_flag; |
osession_type = options.session_type; |
orequest_tty = options.request_tty; |
orequest_tty = options.request_tty; |
otty_flag = tty_flag; |
otty_flag = tty_flag; |
stdin_null_flag = 1; |
stdin_null_flag = 1; |
no_shell_flag = 1; |
options.session_type = SESSION_TYPE_NONE; |
tty_flag = 0; |
tty_flag = 0; |
if (!fork_after_authentication_flag && |
if (!fork_after_authentication_flag && |
(!ono_shell_flag || options.stdio_forward_host != NULL)) |
(osession_type != SESSION_TYPE_NONE || options.stdio_forward_host != NULL)) |
need_controlpersist_detach = 1; |
need_controlpersist_detach = 1; |
fork_after_authentication_flag = 1; |
fork_after_authentication_flag = 1; |
} |
} |
|
|
if (options.control_persist && muxserver_sock == -1) |
if (options.control_persist && muxserver_sock == -1) |
ssh_init_stdio_forwarding(ssh); |
ssh_init_stdio_forwarding(ssh); |
|
|
if (!no_shell_flag) |
if (options.session_type != SESSION_TYPE_NONE) |
id = ssh_session2_open(ssh); |
id = ssh_session2_open(ssh); |
else { |
else { |
ssh_packet_set_interactive(ssh, |
ssh_packet_set_interactive(ssh, |