summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2015-09-11 03:47:28 +0000
committerDamien Miller <djm@mindrot.org>2015-09-16 17:52:04 +1000
commit674b3b68c1d36b2562324927cd03857b565e05e8 (patch)
tree7519039660a2adce9b9cb463dbb3298a8e1e9d29
parentc0f55db7ee00c8202b05cb4b9ad4ce72cc45df41 (diff)
upstream commit
expand %i in ControlPath to UID; bz#2449 patch from Christian Hesse w/ feedback from dtucker@ Upstream-ID: 2ba8d303e555a84e2f2165ab4b324b41e80ab925
-rw-r--r--ssh.c7
-rw-r--r--ssh_config.58
2 files changed, 9 insertions, 6 deletions
diff --git a/ssh.c b/ssh.c
index bf8c9c646..55a496cb1 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.422 2015/09/04 08:21:47 dtucker Exp $ */ 1/* $OpenBSD: ssh.c,v 1.423 2015/09/11 03:47:28 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
@@ -506,7 +506,7 @@ main(int ac, char **av)
506 int i, r, opt, exit_status, use_syslog, config_test = 0; 506 int i, r, opt, exit_status, use_syslog, config_test = 0;
507 char *p, *cp, *line, *argv0, buf[PATH_MAX], *host_arg, *logfile; 507 char *p, *cp, *line, *argv0, buf[PATH_MAX], *host_arg, *logfile;
508 char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; 508 char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV];
509 char cname[NI_MAXHOST]; 509 char cname[NI_MAXHOST], uidstr[32], *conn_hash_hex;
510 struct stat st; 510 struct stat st;
511 struct passwd *pw; 511 struct passwd *pw;
512 int timeout_ms; 512 int timeout_ms;
@@ -516,7 +516,6 @@ main(int ac, char **av)
516 struct addrinfo *addrs = NULL; 516 struct addrinfo *addrs = NULL;
517 struct ssh_digest_ctx *md; 517 struct ssh_digest_ctx *md;
518 u_char conn_hash[SSH_DIGEST_MAX_LENGTH]; 518 u_char conn_hash[SSH_DIGEST_MAX_LENGTH];
519 char *conn_hash_hex;
520 519
521 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 520 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
522 sanitise_stdfd(); 521 sanitise_stdfd();
@@ -1123,6 +1122,7 @@ main(int ac, char **av)
1123 strlcpy(shorthost, thishost, sizeof(shorthost)); 1122 strlcpy(shorthost, thishost, sizeof(shorthost));
1124 shorthost[strcspn(thishost, ".")] = '\0'; 1123 shorthost[strcspn(thishost, ".")] = '\0';
1125 snprintf(portstr, sizeof(portstr), "%d", options.port); 1124 snprintf(portstr, sizeof(portstr), "%d", options.port);
1125 snprintf(uidstr, sizeof(uidstr), "%d", pw->pw_uid);
1126 1126
1127 if ((md = ssh_digest_start(SSH_DIGEST_SHA1)) == NULL || 1127 if ((md = ssh_digest_start(SSH_DIGEST_SHA1)) == NULL ||
1128 ssh_digest_update(md, thishost, strlen(thishost)) < 0 || 1128 ssh_digest_update(md, thishost, strlen(thishost)) < 0 ||
@@ -1165,6 +1165,7 @@ main(int ac, char **av)
1165 "p", portstr, 1165 "p", portstr,
1166 "r", options.user, 1166 "r", options.user,
1167 "u", pw->pw_name, 1167 "u", pw->pw_name,
1168 "i", uidstr,
1168 (char *)NULL); 1169 (char *)NULL);
1169 free(cp); 1170 free(cp);
1170 } 1171 }
diff --git a/ssh_config.5 b/ssh_config.5
index 9c6c2bdac..a4c85217a 100644
--- a/ssh_config.5
+++ b/ssh_config.5
@@ -33,8 +33,8 @@
33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: ssh_config.5,v 1.217 2015/09/04 06:40:45 jmc Exp $ 36.\" $OpenBSD: ssh_config.5,v 1.218 2015/09/11 03:47:28 djm Exp $
37.Dd $Mdocdate: September 4 2015 $ 37.Dd $Mdocdate: September 11 2015 $
38.Dt SSH_CONFIG 5 38.Dt SSH_CONFIG 5
39.Os 39.Os
40.Sh NAME 40.Sh NAME
@@ -538,7 +538,9 @@ the destination port,
538.Ql %r 538.Ql %r
539by the remote login username, 539by the remote login username,
540.Ql %u 540.Ql %u
541by the username of the user running 541by the username and
542.Ql %i
543by the numeric user id (uid) of the user running
542.Xr ssh 1 , and 544.Xr ssh 1 , and
543.Ql \&%C 545.Ql \&%C
544by a hash of the concatenation: %l%h%p%r. 546by a hash of the concatenation: %l%h%p%r.