upstream commit

expand %i in ControlPath to UID; bz#2449

patch from Christian Hesse w/ feedback from dtucker@

Upstream-ID: 2ba8d303e555a84e2f2165ab4b324b41e80ab925
This commit is contained in:
djm@openbsd.org 2015-09-11 03:47:28 +00:00 committed by Damien Miller
parent c0f55db7ee
commit 674b3b68c1
2 changed files with 9 additions and 6 deletions

7
ssh.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: ssh.c,v 1.422 2015/09/04 08:21:47 dtucker Exp $ */ /* $OpenBSD: ssh.c,v 1.423 2015/09/11 03:47:28 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -506,7 +506,7 @@ main(int ac, char **av)
int i, r, opt, exit_status, use_syslog, config_test = 0; int i, r, opt, exit_status, use_syslog, config_test = 0;
char *p, *cp, *line, *argv0, buf[PATH_MAX], *host_arg, *logfile; char *p, *cp, *line, *argv0, buf[PATH_MAX], *host_arg, *logfile;
char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV];
char cname[NI_MAXHOST]; char cname[NI_MAXHOST], uidstr[32], *conn_hash_hex;
struct stat st; struct stat st;
struct passwd *pw; struct passwd *pw;
int timeout_ms; int timeout_ms;
@ -516,7 +516,6 @@ main(int ac, char **av)
struct addrinfo *addrs = NULL; struct addrinfo *addrs = NULL;
struct ssh_digest_ctx *md; struct ssh_digest_ctx *md;
u_char conn_hash[SSH_DIGEST_MAX_LENGTH]; u_char conn_hash[SSH_DIGEST_MAX_LENGTH];
char *conn_hash_hex;
/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
sanitise_stdfd(); sanitise_stdfd();
@ -1123,6 +1122,7 @@ main(int ac, char **av)
strlcpy(shorthost, thishost, sizeof(shorthost)); strlcpy(shorthost, thishost, sizeof(shorthost));
shorthost[strcspn(thishost, ".")] = '\0'; shorthost[strcspn(thishost, ".")] = '\0';
snprintf(portstr, sizeof(portstr), "%d", options.port); snprintf(portstr, sizeof(portstr), "%d", options.port);
snprintf(uidstr, sizeof(uidstr), "%d", pw->pw_uid);
if ((md = ssh_digest_start(SSH_DIGEST_SHA1)) == NULL || if ((md = ssh_digest_start(SSH_DIGEST_SHA1)) == NULL ||
ssh_digest_update(md, thishost, strlen(thishost)) < 0 || ssh_digest_update(md, thishost, strlen(thishost)) < 0 ||
@ -1165,6 +1165,7 @@ main(int ac, char **av)
"p", portstr, "p", portstr,
"r", options.user, "r", options.user,
"u", pw->pw_name, "u", pw->pw_name,
"i", uidstr,
(char *)NULL); (char *)NULL);
free(cp); free(cp);
} }

View File

@ -33,8 +33,8 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: ssh_config.5,v 1.217 2015/09/04 06:40:45 jmc Exp $ .\" $OpenBSD: ssh_config.5,v 1.218 2015/09/11 03:47:28 djm Exp $
.Dd $Mdocdate: September 4 2015 $ .Dd $Mdocdate: September 11 2015 $
.Dt SSH_CONFIG 5 .Dt SSH_CONFIG 5
.Os .Os
.Sh NAME .Sh NAME
@ -538,7 +538,9 @@ the destination port,
.Ql %r .Ql %r
by the remote login username, by the remote login username,
.Ql %u .Ql %u
by the username of the user running by the username and
.Ql %i
by the numeric user id (uid) of the user running
.Xr ssh 1 , and .Xr ssh 1 , and
.Ql \&%C .Ql \&%C
by a hash of the concatenation: %l%h%p%r. by a hash of the concatenation: %l%h%p%r.