version 1.369, 2012/07/02 08:50:03 |
version 1.370, 2012/07/06 01:47:38 |
|
|
/* Initialize the command to execute on remote host. */ |
/* Initialize the command to execute on remote host. */ |
buffer_init(&command); |
buffer_init(&command); |
|
|
if (options.request_tty == REQUEST_TTY_YES || |
|
options.request_tty == REQUEST_TTY_FORCE) |
|
tty_flag = 1; |
|
|
|
/* |
/* |
* Save the command to execute on the remote host in a buffer. There |
* Save the command to execute on the remote host in a buffer. There |
* is no limit on the length of the command, except by the maximum |
* is no limit on the length of the command, except by the maximum |
|
|
*/ |
*/ |
if (!ac) { |
if (!ac) { |
/* No command specified - execute shell on a tty. */ |
/* No command specified - execute shell on a tty. */ |
tty_flag = options.request_tty != REQUEST_TTY_NO; |
|
if (subsystem_flag) { |
if (subsystem_flag) { |
fprintf(stderr, |
fprintf(stderr, |
"You must specify a subsystem to invoke.\n"); |
"You must specify a subsystem to invoke.\n"); |
|
|
fatal("Cannot fork into background without a command " |
fatal("Cannot fork into background without a command " |
"to execute."); |
"to execute."); |
|
|
/* Allocate a tty by default if no command specified. */ |
|
if (buffer_len(&command) == 0) |
|
tty_flag = options.request_tty != REQUEST_TTY_NO; |
|
|
|
/* Force no tty */ |
|
if (options.request_tty == REQUEST_TTY_NO || muxclient_command != 0) |
|
tty_flag = 0; |
|
/* Do not allocate a tty if stdin is not a tty. */ |
|
if ((!isatty(fileno(stdin)) || stdin_null_flag) && |
|
options.request_tty != REQUEST_TTY_FORCE) { |
|
if (tty_flag) |
|
logit("Pseudo-terminal will not be allocated because " |
|
"stdin is not a terminal."); |
|
tty_flag = 0; |
|
} |
|
|
|
/* |
/* |
* Initialize "log" output. Since we are the client all output |
* Initialize "log" output. Since we are the client all output |
* actually goes to stderr. |
* actually goes to stderr. |
|
|
|
|
/* reinit */ |
/* reinit */ |
log_init(argv0, options.log_level, SYSLOG_FACILITY_USER, !use_syslog); |
log_init(argv0, options.log_level, SYSLOG_FACILITY_USER, !use_syslog); |
|
|
|
if (options.request_tty == REQUEST_TTY_YES || |
|
options.request_tty == REQUEST_TTY_FORCE) |
|
tty_flag = 1; |
|
|
|
/* Allocate a tty by default if no command specified. */ |
|
if (buffer_len(&command) == 0) |
|
tty_flag = options.request_tty != REQUEST_TTY_NO; |
|
|
|
/* Force no tty */ |
|
if (options.request_tty == REQUEST_TTY_NO || muxclient_command != 0) |
|
tty_flag = 0; |
|
/* Do not allocate a tty if stdin is not a tty. */ |
|
if ((!isatty(fileno(stdin)) || stdin_null_flag) && |
|
options.request_tty != REQUEST_TTY_FORCE) { |
|
if (tty_flag) |
|
logit("Pseudo-terminal will not be allocated because " |
|
"stdin is not a terminal."); |
|
tty_flag = 0; |
|
} |
|
|
if (options.user == NULL) |
if (options.user == NULL) |
options.user = xstrdup(pw->pw_name); |
options.user = xstrdup(pw->pw_name); |