summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2020-07-17 03:23:10 +0000
committerDamien Miller <djm@mindrot.org>2020-07-17 13:52:46 +1000
commitc4f239944a4351810fd317edf408bdcd5c0102d9 (patch)
treeb2c83f10aad596cc6eba01f94eafe3b43a6bae42 /ssh.c
parentdbaaa01daedb423c38124a72c471982fb08a16fb (diff)
upstream: Add %-TOKEN, environment variable and tilde expansion to
UserKnownHostsFile, allowing the file to be automagically split up in the configuration (eg bz#1654). ok djm@, man page parts jmc@ OpenBSD-Commit-ID: 7e1b406caf147638bb51558836a72d6cc0bd1b18
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/ssh.c b/ssh.c
index b13783d43..5c93c3d2f 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.531 2020/07/05 23:59:45 djm Exp $ */ 1/* $OpenBSD: ssh.c,v 1.532 2020/07/17 03:23:10 dtucker 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
@@ -654,6 +654,7 @@ main(int ac, char **av)
654 struct Forward fwd; 654 struct Forward fwd;
655 struct addrinfo *addrs = NULL; 655 struct addrinfo *addrs = NULL;
656 size_t n, len; 656 size_t n, len;
657 u_int j;
657 658
658 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 659 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
659 sanitise_stdfd(); 660 sanitise_stdfd();
@@ -1427,6 +1428,21 @@ main(int ac, char **av)
1427 options.forward_agent_sock_path = cp; 1428 options.forward_agent_sock_path = cp;
1428 } 1429 }
1429 1430
1431 for (j = 0; j < options.num_user_hostfiles; j++) {
1432 if (options.user_hostfiles[j] != NULL) {
1433 cp = tilde_expand_filename(options.user_hostfiles[j],
1434 getuid());
1435 p = default_client_percent_dollar_expand(cp,
1436 pw->pw_dir, host, options.user, pw->pw_name);
1437 if (strcmp(options.user_hostfiles[j], p) != 0)
1438 debug3("expanded UserKnownHostsFile '%s' -> "
1439 "'%s'", options.user_hostfiles[j], p);
1440 free(options.user_hostfiles[j]);
1441 free(cp);
1442 options.user_hostfiles[j] = p;
1443 }
1444 }
1445
1430 for (i = 0; i < options.num_local_forwards; i++) { 1446 for (i = 0; i < options.num_local_forwards; i++) {
1431 if (options.local_forwards[i].listen_path != NULL) { 1447 if (options.local_forwards[i].listen_path != NULL) {
1432 cp = options.local_forwards[i].listen_path; 1448 cp = options.local_forwards[i].listen_path;