diff options
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 47 |
1 files changed, 25 insertions, 22 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.368 2011/10/24 02:10:46 djm Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.370 2012/07/06 01:47:38 djm 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 |
@@ -638,10 +638,6 @@ main(int ac, char **av) | |||
638 | /* Initialize the command to execute on remote host. */ | 638 | /* Initialize the command to execute on remote host. */ |
639 | buffer_init(&command); | 639 | buffer_init(&command); |
640 | 640 | ||
641 | if (options.request_tty == REQUEST_TTY_YES || | ||
642 | options.request_tty == REQUEST_TTY_FORCE) | ||
643 | tty_flag = 1; | ||
644 | |||
645 | /* | 641 | /* |
646 | * Save the command to execute on the remote host in a buffer. There | 642 | * Save the command to execute on the remote host in a buffer. There |
647 | * is no limit on the length of the command, except by the maximum | 643 | * is no limit on the length of the command, except by the maximum |
@@ -649,7 +645,6 @@ main(int ac, char **av) | |||
649 | */ | 645 | */ |
650 | if (!ac) { | 646 | if (!ac) { |
651 | /* No command specified - execute shell on a tty. */ | 647 | /* No command specified - execute shell on a tty. */ |
652 | tty_flag = options.request_tty != REQUEST_TTY_NO; | ||
653 | if (subsystem_flag) { | 648 | if (subsystem_flag) { |
654 | fprintf(stderr, | 649 | fprintf(stderr, |
655 | "You must specify a subsystem to invoke.\n"); | 650 | "You must specify a subsystem to invoke.\n"); |
@@ -670,22 +665,6 @@ main(int ac, char **av) | |||
670 | fatal("Cannot fork into background without a command " | 665 | fatal("Cannot fork into background without a command " |
671 | "to execute."); | 666 | "to execute."); |
672 | 667 | ||
673 | /* Allocate a tty by default if no command specified. */ | ||
674 | if (buffer_len(&command) == 0) | ||
675 | tty_flag = options.request_tty != REQUEST_TTY_NO; | ||
676 | |||
677 | /* Force no tty */ | ||
678 | if (options.request_tty == REQUEST_TTY_NO || muxclient_command != 0) | ||
679 | tty_flag = 0; | ||
680 | /* Do not allocate a tty if stdin is not a tty. */ | ||
681 | if ((!isatty(fileno(stdin)) || stdin_null_flag) && | ||
682 | options.request_tty != REQUEST_TTY_FORCE) { | ||
683 | if (tty_flag) | ||
684 | logit("Pseudo-terminal will not be allocated because " | ||
685 | "stdin is not a terminal."); | ||
686 | tty_flag = 0; | ||
687 | } | ||
688 | |||
689 | /* | 668 | /* |
690 | * Initialize "log" output. Since we are the client all output | 669 | * Initialize "log" output. Since we are the client all output |
691 | * actually goes to stderr. | 670 | * actually goes to stderr. |
@@ -721,6 +700,26 @@ main(int ac, char **av) | |||
721 | /* reinit */ | 700 | /* reinit */ |
722 | log_init(argv0, options.log_level, SYSLOG_FACILITY_USER, !use_syslog); | 701 | log_init(argv0, options.log_level, SYSLOG_FACILITY_USER, !use_syslog); |
723 | 702 | ||
703 | if (options.request_tty == REQUEST_TTY_YES || | ||
704 | options.request_tty == REQUEST_TTY_FORCE) | ||
705 | tty_flag = 1; | ||
706 | |||
707 | /* Allocate a tty by default if no command specified. */ | ||
708 | if (buffer_len(&command) == 0) | ||
709 | tty_flag = options.request_tty != REQUEST_TTY_NO; | ||
710 | |||
711 | /* Force no tty */ | ||
712 | if (options.request_tty == REQUEST_TTY_NO || muxclient_command != 0) | ||
713 | tty_flag = 0; | ||
714 | /* Do not allocate a tty if stdin is not a tty. */ | ||
715 | if ((!isatty(fileno(stdin)) || stdin_null_flag) && | ||
716 | options.request_tty != REQUEST_TTY_FORCE) { | ||
717 | if (tty_flag) | ||
718 | logit("Pseudo-terminal will not be allocated because " | ||
719 | "stdin is not a terminal."); | ||
720 | tty_flag = 0; | ||
721 | } | ||
722 | |||
724 | seed_rng(); | 723 | seed_rng(); |
725 | 724 | ||
726 | if (options.user == NULL) | 725 | if (options.user == NULL) |
@@ -1359,6 +1358,10 @@ ssh_session2_setup(int id, int success, void *arg) | |||
1359 | packet_send(); | 1358 | packet_send(); |
1360 | } | 1359 | } |
1361 | 1360 | ||
1361 | /* Tell the packet module whether this is an interactive session. */ | ||
1362 | packet_set_interactive(interactive, | ||
1363 | options.ip_qos_interactive, options.ip_qos_bulk); | ||
1364 | |||
1362 | client_session2_setup(id, tty_flag, subsystem_flag, getenv("TERM"), | 1365 | client_session2_setup(id, tty_flag, subsystem_flag, getenv("TERM"), |
1363 | NULL, fileno(stdin), &command, environ); | 1366 | NULL, fileno(stdin), &command, environ); |
1364 | } | 1367 | } |