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 40e63c32..d25960bc 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh.c,v 1.478 2018/06/01 03:11:49 djm Exp $ */
+/* $OpenBSD: ssh.c,v 1.479 2018/06/01 03:33:53 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1278,7 +1278,8 @@ main(int ac, char **av)
strlcpy(shorthost, thishost, sizeof(shorthost));
shorthost[strcspn(thishost, ".")] = '\0';
snprintf(portstr, sizeof(portstr), "%d", options.port);
- snprintf(uidstr, sizeof(uidstr), "%d", pw->pw_uid);
+ snprintf(uidstr, sizeof(uidstr), "%llu",
+ (unsigned long long)pw->pw_uid);
if ((md = ssh_digest_start(SSH_DIGEST_SHA1)) == NULL ||
ssh_digest_update(md, thishost, strlen(thishost)) < 0 ||
@@ -1303,6 +1304,7 @@ main(int ac, char **av)
"L", shorthost,
"d", pw->pw_dir,
"h", host,
+ "i", uidstr,
"l", thishost,
"n", host_arg,
"p", portstr,
@@ -1323,6 +1325,7 @@ main(int ac, char **av)
"C", conn_hash_hex,
"L", shorthost,
"h", host,
+ "i", uidstr,
"l", thishost,
"n", host_arg,
"p", portstr,
@@ -1501,9 +1504,14 @@ main(int ac, char **av)
} else {
p = tilde_expand_filename(options.identity_agent,
original_real_uid);
- cp = percent_expand(p, "d", pw->pw_dir,
- "u", pw->pw_name, "l", thishost, "h", host,
- "r", options.user, (char *)NULL);
+ cp = percent_expand(p,
+ "d", pw->pw_dir,
+ "h", host,
+ "i", uidstr,
+ "l", thishost,
+ "r", options.user,
+ "u", pw->pw_name,
+ (char *)NULL);
setenv(SSH_AUTHSOCKET_ENV_NAME, cp, 1);
free(cp);
free(p);
@@ -1908,6 +1916,7 @@ ssh_session2(struct ssh *ssh, struct passwd *pw)
"L", shorthost,
"d", pw->pw_dir,
"h", host,
+ "i", uidstr,
"l", thishost,
"n", host_arg,
"p", portstr,
@@ -2106,9 +2115,14 @@ load_public_identity_files(struct passwd *pw)
for (i = 0; i < options.num_certificate_files; i++) {
cp = tilde_expand_filename(options.certificate_files[i],
original_real_uid);
- filename = percent_expand(cp, "d", pw->pw_dir,
- "u", pw->pw_name, "l", thishost, "h", host,
- "r", options.user, (char *)NULL);
+ filename = percent_expand(cp,
+ "d", pw->pw_dir,
+ "h", host,
+ "i", host,
+ "l", thishost,
+ "r", options.user,
+ "u", pw->pw_name,
+ (char *)NULL);
free(cp);
public = key_load_public(filename, NULL);