summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2018-06-15 07:01:11 +0000
committerdjm <djm@openbsd.org>2018-06-15 07:01:11 +0000
commitdcbf2ccf67fe7f1d555801da98b9b26a81de9e87 (patch)
tree4df3a1df89f4d7bb80a97e252a3bf809f5b1d409
parentClean up some whitespace and polish a few comments. Reduces noise in (diff)
downloadwireguard-openbsd-dcbf2ccf67fe7f1d555801da98b9b26a81de9e87.tar.xz
wireguard-openbsd-dcbf2ccf67fe7f1d555801da98b9b26a81de9e87.zip
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
-rw-r--r--usr.bin/ssh/uidswap.c7
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)