From 249fce85caa587b9da83426400080e92ad735948 Mon Sep 17 00:00:00 2001 From: Przemyslaw Pawelczyk Date: Sun, 18 Mar 2012 14:26:23 +0100 Subject: [PATCH] Move log init and config reading before TTY affairs. Crucial code flow fix to make RequestTTY option fully working, thus avoiding superfluous message: Pseudo-terminal will not be allocated because stdin is not a terminal. --- ssh.c | 66 ++++++++++++++++++++++++++++++++-------------------------------- 1 files changed, 33 insertions(+), 33 deletions(-) diff --git a/ssh.c b/ssh.c index 68e1315..9a2553f 100644 --- a/ssh.c +++ b/ssh.c @@ -638,6 +638,39 @@ main(int ac, char **av) /* Initialize the command to execute on remote host. */ buffer_init(&command); + /* + * Initialize "log" output. Since we are the client all output + * actually goes to stderr. + */ + log_init(argv0, + options.log_level == -1 ? SYSLOG_LEVEL_INFO : options.log_level, + SYSLOG_FACILITY_USER, !use_syslog); + + /* + * Read per-user configuration file. Ignore the system wide config + * file if the user specifies a config file on the command line. + */ + if (config != NULL) { + if (!read_config_file(config, host, &options, 0)) + fatal("Can't open user config file %.100s: " + "%.100s", config, strerror(errno)); + } else { + r = snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, + _PATH_SSH_USER_CONFFILE); + if (r > 0 && (size_t)r < sizeof(buf)) + (void)read_config_file(buf, host, &options, 1); + + /* Read systemwide configuration file after user config. */ + (void)read_config_file(_PATH_HOST_CONFIG_FILE, host, + &options, 0); + } + + /* Fill configuration defaults. */ + fill_default_options(&options); + + /* reinit */ + 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; @@ -686,41 +719,8 @@ main(int ac, char **av) tty_flag = 0; } - /* - * Initialize "log" output. Since we are the client all output - * actually goes to stderr. - */ - log_init(argv0, - options.log_level == -1 ? SYSLOG_LEVEL_INFO : options.log_level, - SYSLOG_FACILITY_USER, !use_syslog); - - /* - * Read per-user configuration file. Ignore the system wide config - * file if the user specifies a config file on the command line. - */ - if (config != NULL) { - if (!read_config_file(config, host, &options, 0)) - fatal("Can't open user config file %.100s: " - "%.100s", config, strerror(errno)); - } else { - r = snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, - _PATH_SSH_USER_CONFFILE); - if (r > 0 && (size_t)r < sizeof(buf)) - (void)read_config_file(buf, host, &options, 1); - - /* Read systemwide configuration file after user config. */ - (void)read_config_file(_PATH_HOST_CONFIG_FILE, host, - &options, 0); - } - - /* Fill configuration defaults. */ - fill_default_options(&options); - channel_set_af(options.address_family); - /* reinit */ - log_init(argv0, options.log_level, SYSLOG_FACILITY_USER, !use_syslog); - seed_rng(); if (options.user == NULL) -- 1.7.9.1