diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2018-06-15 07:01:12 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2018-06-15 07:01:12 +0000 |
commit | b96311432952b73c2423b20449a7387a4afd303a (patch) | |
tree | 6fd0c3697826db6a354c2d46a0c094124a3965fb /usr.bin | |
parent | eeeee004ddf4cd42b507615b0717c77385062598 (diff) |
invalidate supplemental group cache used by temporarily_use_uid()
when the target uid differs; could cause failure to read
authorized_keys under some configurations. patch by Jakub Jelen
via bz2873; ok dtucker, markus
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/uidswap.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/ssh/uidswap.c b/usr.bin/ssh/uidswap.c index 01f68775cf1..23e8f47cac9 100644 --- a/usr.bin/ssh/uidswap.c +++ b/usr.bin/ssh/uidswap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uidswap.c,v 1.39 2015/06/24 01:49:19 dtucker Exp $ */ +/* $OpenBSD: uidswap.c,v 1.40 2018/06/15 07:01:11 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -38,7 +38,7 @@ /* Saved effective uid. */ static int privileged = 0; static int temporarily_use_uid_effective = 0; -static uid_t saved_euid = 0; +static uid_t saved_euid, user_groups_uid; static gid_t saved_egid; static gid_t saved_egroups[NGROUPS_MAX], user_groups[NGROUPS_MAX]; static int saved_egroupslen = -1, user_groupslen = -1; @@ -67,13 +67,14 @@ temporarily_use_uid(struct passwd *pw) fatal("getgroups: %.100s", strerror(errno)); /* set and save the user's groups */ - if (user_groupslen == -1) { + if (user_groupslen == -1 || user_groups_uid != pw->pw_uid) { if (initgroups(pw->pw_name, pw->pw_gid) < 0) fatal("initgroups: %s: %.100s", pw->pw_name, strerror(errno)); user_groupslen = getgroups(NGROUPS_MAX, user_groups); if (user_groupslen < 0) fatal("getgroups: %.100s", strerror(errno)); + user_groups_uid = pw->pw_uid; } /* Set the effective uid to the given (unprivileged) uid. */ if (setgroups(user_groupslen, user_groups) < 0) |