diff options
author | Damien Miller <djm@mindrot.org> | 2006-03-31 23:13:21 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2006-03-31 23:13:21 +1100 |
commit | 6b1d53c2b090130440c3459876c0033c4e5a466a (patch) | |
tree | 941e967011a9fd8bb22d796e4c91f515ab416bac /ssh.c | |
parent | 3f9418893e1254bda3b87e7d3af7029d11b0a6c7 (diff) |
- djm@cvs.openbsd.org 2006/03/30 10:41:25
[ssh.c ssh_config.5]
add percent escape chars to the IdentityFile option, bz #1159 based
on a patch by imaging AT math.ualberta.ca; feedback and ok dtucker@
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.274 2006/03/28 00:12:31 deraadt Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.275 2006/03/30 10:41:25 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 |
@@ -647,15 +647,15 @@ main(int ac, char **av) | |||
647 | options.control_path = NULL; | 647 | options.control_path = NULL; |
648 | 648 | ||
649 | if (options.control_path != NULL) { | 649 | if (options.control_path != NULL) { |
650 | char me[NI_MAXHOST]; | 650 | char thishost[NI_MAXHOST]; |
651 | 651 | ||
652 | if (gethostname(me, sizeof(me)) == -1) | 652 | if (gethostname(thishost, sizeof(thishost)) == -1) |
653 | fatal("gethostname: %s", strerror(errno)); | 653 | fatal("gethostname: %s", strerror(errno)); |
654 | snprintf(buf, sizeof(buf), "%d", options.port); | 654 | snprintf(buf, sizeof(buf), "%d", options.port); |
655 | cp = tilde_expand_filename(options.control_path, | 655 | cp = tilde_expand_filename(options.control_path, |
656 | original_real_uid); | 656 | original_real_uid); |
657 | options.control_path = percent_expand(cp, "p", buf, "h", host, | 657 | options.control_path = percent_expand(cp, "p", buf, "h", host, |
658 | "r", options.user, "l", me, (char *)NULL); | 658 | "r", options.user, "l", thishost, (char *)NULL); |
659 | xfree(cp); | 659 | xfree(cp); |
660 | } | 660 | } |
661 | if (mux_command != 0 && options.control_path == NULL) | 661 | if (mux_command != 0 && options.control_path == NULL) |
@@ -1194,9 +1194,10 @@ ssh_session2(void) | |||
1194 | static void | 1194 | static void |
1195 | load_public_identity_files(void) | 1195 | load_public_identity_files(void) |
1196 | { | 1196 | { |
1197 | char *filename; | 1197 | char *filename, *cp, thishost[NI_MAXHOST]; |
1198 | int i = 0; | 1198 | int i = 0; |
1199 | Key *public; | 1199 | Key *public; |
1200 | struct passwd *pw; | ||
1200 | #ifdef SMARTCARD | 1201 | #ifdef SMARTCARD |
1201 | Key **keys; | 1202 | Key **keys; |
1202 | 1203 | ||
@@ -1220,9 +1221,18 @@ load_public_identity_files(void) | |||
1220 | xfree(keys); | 1221 | xfree(keys); |
1221 | } | 1222 | } |
1222 | #endif /* SMARTCARD */ | 1223 | #endif /* SMARTCARD */ |
1224 | if ((pw = getpwuid(original_real_uid)) == NULL) | ||
1225 | fatal("load_public_identity_files: getpwuid failed"); | ||
1226 | if (gethostname(thishost, sizeof(thishost)) == -1) | ||
1227 | fatal("load_public_identity_files: gethostname: %s", | ||
1228 | strerror(errno)); | ||
1223 | for (; i < options.num_identity_files; i++) { | 1229 | for (; i < options.num_identity_files; i++) { |
1224 | filename = tilde_expand_filename(options.identity_files[i], | 1230 | cp = tilde_expand_filename(options.identity_files[i], |
1225 | original_real_uid); | 1231 | original_real_uid); |
1232 | filename = percent_expand(cp, "d", pw->pw_dir, | ||
1233 | "u", pw->pw_name, "l", thishost, "h", host, | ||
1234 | "r", options.user, (char *)NULL); | ||
1235 | xfree(cp); | ||
1226 | public = key_load_public(filename, NULL); | 1236 | public = key_load_public(filename, NULL); |
1227 | debug("identity file %s type %d", filename, | 1237 | debug("identity file %s type %d", filename, |
1228 | public ? public->type : -1); | 1238 | public ? public->type : -1); |