diff options
author | djm@openbsd.org <djm@openbsd.org> | 2018-06-01 03:33:53 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2018-06-01 13:35:59 +1000 |
commit | 9c935dd9bf05628826ad2495d3e8bdf3d3271c21 (patch) | |
tree | 35ccf63e51d3daf2fa927b843d813295e41e96e6 /session.c | |
parent | d8748b91d1d6c108c0c260ed41fa55f37b9ef34b (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 'session.c')
-rw-r--r-- | session.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: session.c,v 1.294 2018/03/03 03:15:51 djm Exp $ */ | 1 | /* $OpenBSD: session.c,v 1.295 2018/06/01 03:33:53 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
4 | * All rights reserved | 4 | * All rights reserved |
@@ -1324,7 +1324,7 @@ safely_chroot(const char *path, uid_t uid) | |||
1324 | void | 1324 | void |
1325 | do_setusercontext(struct passwd *pw) | 1325 | do_setusercontext(struct passwd *pw) |
1326 | { | 1326 | { |
1327 | char *chroot_path, *tmp; | 1327 | char uidstr[32], *chroot_path, *tmp; |
1328 | 1328 | ||
1329 | platform_setusercontext(pw); | 1329 | platform_setusercontext(pw); |
1330 | 1330 | ||
@@ -1356,8 +1356,10 @@ do_setusercontext(struct passwd *pw) | |||
1356 | strcasecmp(options.chroot_directory, "none") != 0) { | 1356 | strcasecmp(options.chroot_directory, "none") != 0) { |
1357 | tmp = tilde_expand_filename(options.chroot_directory, | 1357 | tmp = tilde_expand_filename(options.chroot_directory, |
1358 | pw->pw_uid); | 1358 | pw->pw_uid); |
1359 | snprintf(uidstr, sizeof(uidstr), "%llu", | ||
1360 | (unsigned long long)pw->pw_uid); | ||
1359 | chroot_path = percent_expand(tmp, "h", pw->pw_dir, | 1361 | chroot_path = percent_expand(tmp, "h", pw->pw_dir, |
1360 | "u", pw->pw_name, (char *)NULL); | 1362 | "u", pw->pw_name, "U", uidstr, (char *)NULL); |
1361 | safely_chroot(chroot_path, pw->pw_uid); | 1363 | safely_chroot(chroot_path, pw->pw_uid); |
1362 | free(tmp); | 1364 | free(tmp); |
1363 | free(chroot_path); | 1365 | free(chroot_path); |