summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2018-06-01 03:33:53 +0000
committerDamien Miller <djm@mindrot.org>2018-06-01 13:35:59 +1000
commit9c935dd9bf05628826ad2495d3e8bdf3d3271c21 (patch)
tree35ccf63e51d3daf2fa927b843d813295e41e96e6 /ssh.c
parentd8748b91d1d6c108c0c260ed41fa55f37b9ef34b (diff)
upstream: make UID available as a %-expansion everywhere that the
username is available currently. In the client this is via %i, in the server %U (since %i was already used in the client in some places for this, but used for something different in the server); bz#2870, ok dtucker@ OpenBSD-Commit-ID: c7e912b0213713316cb55db194b3a6415b3d4b95
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/ssh.c b/ssh.c
index 40e63c325..d25960bce 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.478 2018/06/01 03:11:49 djm Exp $ */ 1/* $OpenBSD: ssh.c,v 1.479 2018/06/01 03:33:53 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
@@ -1278,7 +1278,8 @@ main(int ac, char **av)
1278 strlcpy(shorthost, thishost, sizeof(shorthost)); 1278 strlcpy(shorthost, thishost, sizeof(shorthost));
1279 shorthost[strcspn(thishost, ".")] = '\0'; 1279 shorthost[strcspn(thishost, ".")] = '\0';
1280 snprintf(portstr, sizeof(portstr), "%d", options.port); 1280 snprintf(portstr, sizeof(portstr), "%d", options.port);
1281 snprintf(uidstr, sizeof(uidstr), "%d", pw->pw_uid); 1281 snprintf(uidstr, sizeof(uidstr), "%llu",
1282 (unsigned long long)pw->pw_uid);
1282 1283
1283 if ((md = ssh_digest_start(SSH_DIGEST_SHA1)) == NULL || 1284 if ((md = ssh_digest_start(SSH_DIGEST_SHA1)) == NULL ||
1284 ssh_digest_update(md, thishost, strlen(thishost)) < 0 || 1285 ssh_digest_update(md, thishost, strlen(thishost)) < 0 ||
@@ -1303,6 +1304,7 @@ main(int ac, char **av)
1303 "L", shorthost, 1304 "L", shorthost,
1304 "d", pw->pw_dir, 1305 "d", pw->pw_dir,
1305 "h", host, 1306 "h", host,
1307 "i", uidstr,
1306 "l", thishost, 1308 "l", thishost,
1307 "n", host_arg, 1309 "n", host_arg,
1308 "p", portstr, 1310 "p", portstr,
@@ -1323,6 +1325,7 @@ main(int ac, char **av)
1323 "C", conn_hash_hex, 1325 "C", conn_hash_hex,
1324 "L", shorthost, 1326 "L", shorthost,
1325 "h", host, 1327 "h", host,
1328 "i", uidstr,
1326 "l", thishost, 1329 "l", thishost,
1327 "n", host_arg, 1330 "n", host_arg,
1328 "p", portstr, 1331 "p", portstr,
@@ -1501,9 +1504,14 @@ main(int ac, char **av)
1501 } else { 1504 } else {
1502 p = tilde_expand_filename(options.identity_agent, 1505 p = tilde_expand_filename(options.identity_agent,
1503 original_real_uid); 1506 original_real_uid);
1504 cp = percent_expand(p, "d", pw->pw_dir, 1507 cp = percent_expand(p,
1505 "u", pw->pw_name, "l", thishost, "h", host, 1508 "d", pw->pw_dir,
1506 "r", options.user, (char *)NULL); 1509 "h", host,
1510 "i", uidstr,
1511 "l", thishost,
1512 "r", options.user,
1513 "u", pw->pw_name,
1514 (char *)NULL);
1507 setenv(SSH_AUTHSOCKET_ENV_NAME, cp, 1); 1515 setenv(SSH_AUTHSOCKET_ENV_NAME, cp, 1);
1508 free(cp); 1516 free(cp);
1509 free(p); 1517 free(p);
@@ -1908,6 +1916,7 @@ ssh_session2(struct ssh *ssh, struct passwd *pw)
1908 "L", shorthost, 1916 "L", shorthost,
1909 "d", pw->pw_dir, 1917 "d", pw->pw_dir,
1910 "h", host, 1918 "h", host,
1919 "i", uidstr,
1911 "l", thishost, 1920 "l", thishost,
1912 "n", host_arg, 1921 "n", host_arg,
1913 "p", portstr, 1922 "p", portstr,
@@ -2106,9 +2115,14 @@ load_public_identity_files(struct passwd *pw)
2106 for (i = 0; i < options.num_certificate_files; i++) { 2115 for (i = 0; i < options.num_certificate_files; i++) {
2107 cp = tilde_expand_filename(options.certificate_files[i], 2116 cp = tilde_expand_filename(options.certificate_files[i],
2108 original_real_uid); 2117 original_real_uid);
2109 filename = percent_expand(cp, "d", pw->pw_dir, 2118 filename = percent_expand(cp,
2110 "u", pw->pw_name, "l", thishost, "h", host, 2119 "d", pw->pw_dir,
2111 "r", options.user, (char *)NULL); 2120 "h", host,
2121 "i", host,
2122 "l", thishost,
2123 "r", options.user,
2124 "u", pw->pw_name,
2125 (char *)NULL);
2112 free(cp); 2126 free(cp);
2113 2127
2114 public = key_load_public(filename, NULL); 2128 public = key_load_public(filename, NULL);