version 1.381, 2013/07/25 00:29:10 |
version 1.382, 2013/10/14 22:22:04 |
|
|
char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; |
char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; |
struct stat st; |
struct stat st; |
struct passwd *pw; |
struct passwd *pw; |
int dummy, timeout_ms; |
int timeout_ms; |
extern int optind, optreset; |
extern int optind, optreset; |
extern char *optarg; |
extern char *optarg; |
struct servent *sp; |
|
Forward fwd; |
Forward fwd; |
|
|
/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ |
/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ |
|
|
options.request_tty = REQUEST_TTY_NO; |
options.request_tty = REQUEST_TTY_NO; |
break; |
break; |
case 'o': |
case 'o': |
dummy = 1; |
|
line = xstrdup(optarg); |
line = xstrdup(optarg); |
if (process_config_line(&options, host ? host : "", |
if (process_config_line(&options, pw, host ? host : "", |
line, "command-line", 0, &dummy, SSHCONF_USERCONF) |
line, "command-line", 0, NULL, SSHCONF_USERCONF) |
!= 0) |
!= 0) |
exit(255); |
exit(255); |
free(line); |
free(line); |
|
|
*/ |
*/ |
if (config != NULL) { |
if (config != NULL) { |
if (strcasecmp(config, "none") != 0 && |
if (strcasecmp(config, "none") != 0 && |
!read_config_file(config, host, &options, SSHCONF_USERCONF)) |
!read_config_file(config, pw, host, &options, |
|
SSHCONF_USERCONF)) |
fatal("Can't open user config file %.100s: " |
fatal("Can't open user config file %.100s: " |
"%.100s", config, strerror(errno)); |
"%.100s", config, strerror(errno)); |
} else { |
} else { |
r = snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, |
r = snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, |
_PATH_SSH_USER_CONFFILE); |
_PATH_SSH_USER_CONFFILE); |
if (r > 0 && (size_t)r < sizeof(buf)) |
if (r > 0 && (size_t)r < sizeof(buf)) |
(void)read_config_file(buf, host, &options, |
(void)read_config_file(buf, pw, host, &options, |
SSHCONF_CHECKPERM|SSHCONF_USERCONF); |
SSHCONF_CHECKPERM|SSHCONF_USERCONF); |
|
|
/* Read systemwide configuration file after user config. */ |
/* Read systemwide configuration file after user config. */ |
(void)read_config_file(_PATH_HOST_CONFIG_FILE, host, |
(void)read_config_file(_PATH_HOST_CONFIG_FILE, pw, host, |
&options, 0); |
&options, 0); |
} |
} |
|
|
|
|
options.user = xstrdup(pw->pw_name); |
options.user = xstrdup(pw->pw_name); |
|
|
/* Get default port if port has not been set. */ |
/* Get default port if port has not been set. */ |
if (options.port == 0) { |
if (options.port == 0) |
sp = getservbyname(SSH_SERVICE_NAME, "tcp"); |
options.port = default_ssh_port(); |
options.port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT; |
|
} |
|
|
|
/* preserve host name given on command line for %n expansion */ |
/* preserve host name given on command line for %n expansion */ |
host_arg = host; |
host_arg = host; |