summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2012-07-06 13:45:01 +1000
committerDamien Miller <djm@mindrot.org>2012-07-06 13:45:01 +1000
commitfff9f095e2f47a4d554b93a247cbcaca5a3baecf (patch)
tree17b09fe5c66c1c51c4080d496cd5ebc2e9d104c1
parentab523b02467f36a2f85c1a8bff6cf2fd4297fb12 (diff)
- djm@cvs.openbsd.org 2012/07/06 01:47:38
[ssh.c] move setting of tty_flag to after config parsing so RequestTTY options are correctly picked up. bz#1995 patch from przemoc AT gmail.com; ok dtucker@
-rw-r--r--ChangeLog5
-rw-r--r--ssh.c43
2 files changed, 26 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 68811e63b..07c17486d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,11 @@
16 fix memory leak of passed-in environment variables and connection 16 fix memory leak of passed-in environment variables and connection
17 context when new session message is malformed; bz#2003 from Bert.Wesarg 17 context when new session message is malformed; bz#2003 from Bert.Wesarg
18 AT googlemail.com 18 AT googlemail.com
19 - djm@cvs.openbsd.org 2012/07/06 01:47:38
20 [ssh.c]
21 move setting of tty_flag to after config parsing so RequestTTY options
22 are correctly picked up. bz#1995 patch from przemoc AT gmail.com;
23 ok dtucker@
19 24
2020120704 2520120704
21 - (dtucker) [configure.ac openbsd-compat/bsd-misc.h] Add setlinebuf for 26 - (dtucker) [configure.ac openbsd-compat/bsd-misc.h] Add setlinebuf for
diff --git a/ssh.c b/ssh.c
index 3c376d0ff..3f61eb028 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.369 2012/07/02 08:50:03 dtucker 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)