diff options
author | Damien Miller <djm@mindrot.org> | 2013-10-15 12:13:05 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2013-10-15 12:13:05 +1100 |
commit | 194fd904d8597a274b93e075b2047afdf5a175d4 (patch) | |
tree | e8bd17b8455a41b3dc493b2b69933b8ef0cbfff7 /ssh.c | |
parent | 71df752de2a04f423b1cd18d961a79f4fbccbcee (diff) |
- djm@cvs.openbsd.org 2013/10/14 22:22:05
[readconf.c readconf.h ssh-keysign.c ssh.c ssh_config.5]
add a "Match" keyword to ssh_config that allows matching on hostname,
user and result of arbitrary commands. "nice work" markus@
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.381 2013/07/25 00:29:10 djm Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.382 2013/10/14 22:22:04 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 |
@@ -242,7 +242,7 @@ main(int ac, char **av) | |||
242 | char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; | 242 | char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; |
243 | struct stat st; | 243 | struct stat st; |
244 | struct passwd *pw; | 244 | struct passwd *pw; |
245 | int dummy, timeout_ms; | 245 | int timeout_ms; |
246 | extern int optind, optreset; | 246 | extern int optind, optreset; |
247 | extern char *optarg; | 247 | extern char *optarg; |
248 | 248 | ||
@@ -595,10 +595,9 @@ main(int ac, char **av) | |||
595 | options.request_tty = REQUEST_TTY_NO; | 595 | options.request_tty = REQUEST_TTY_NO; |
596 | break; | 596 | break; |
597 | case 'o': | 597 | case 'o': |
598 | dummy = 1; | ||
599 | line = xstrdup(optarg); | 598 | line = xstrdup(optarg); |
600 | if (process_config_line(&options, host ? host : "", | 599 | if (process_config_line(&options, pw, host ? host : "", |
601 | line, "command-line", 0, &dummy, SSHCONF_USERCONF) | 600 | line, "command-line", 0, NULL, SSHCONF_USERCONF) |
602 | != 0) | 601 | != 0) |
603 | exit(255); | 602 | exit(255); |
604 | free(line); | 603 | free(line); |
@@ -703,18 +702,19 @@ main(int ac, char **av) | |||
703 | */ | 702 | */ |
704 | if (config != NULL) { | 703 | if (config != NULL) { |
705 | if (strcasecmp(config, "none") != 0 && | 704 | if (strcasecmp(config, "none") != 0 && |
706 | !read_config_file(config, host, &options, SSHCONF_USERCONF)) | 705 | !read_config_file(config, pw, host, &options, |
706 | SSHCONF_USERCONF)) | ||
707 | fatal("Can't open user config file %.100s: " | 707 | fatal("Can't open user config file %.100s: " |
708 | "%.100s", config, strerror(errno)); | 708 | "%.100s", config, strerror(errno)); |
709 | } else { | 709 | } else { |
710 | r = snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, | 710 | r = snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, |
711 | _PATH_SSH_USER_CONFFILE); | 711 | _PATH_SSH_USER_CONFFILE); |
712 | if (r > 0 && (size_t)r < sizeof(buf)) | 712 | if (r > 0 && (size_t)r < sizeof(buf)) |
713 | (void)read_config_file(buf, host, &options, | 713 | (void)read_config_file(buf, pw, host, &options, |
714 | SSHCONF_CHECKPERM|SSHCONF_USERCONF); | 714 | SSHCONF_CHECKPERM|SSHCONF_USERCONF); |
715 | 715 | ||
716 | /* Read systemwide configuration file after user config. */ | 716 | /* Read systemwide configuration file after user config. */ |
717 | (void)read_config_file(_PATH_HOST_CONFIG_FILE, host, | 717 | (void)read_config_file(_PATH_HOST_CONFIG_FILE, pw, host, |
718 | &options, 0); | 718 | &options, 0); |
719 | } | 719 | } |
720 | 720 | ||
@@ -752,10 +752,8 @@ main(int ac, char **av) | |||
752 | options.user = xstrdup(pw->pw_name); | 752 | options.user = xstrdup(pw->pw_name); |
753 | 753 | ||
754 | /* Get default port if port has not been set. */ | 754 | /* Get default port if port has not been set. */ |
755 | if (options.port == 0) { | 755 | if (options.port == 0) |
756 | sp = getservbyname(SSH_SERVICE_NAME, "tcp"); | 756 | options.port = default_ssh_port(); |
757 | options.port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT; | ||
758 | } | ||
759 | 757 | ||
760 | /* preserve host name given on command line for %n expansion */ | 758 | /* preserve host name given on command line for %n expansion */ |
761 | host_arg = host; | 759 | host_arg = host; |