|
|
810d56 |
From 26f96ca10ad0ec5da9b05b99de1e1ccea15a11be Mon Sep 17 00:00:00 2001
|
|
|
810d56 |
From: "djm@openbsd.org" <djm@openbsd.org>
|
|
|
810d56 |
Date: Fri, 15 Jun 2018 07:01:11 +0000
|
|
|
810d56 |
Subject: [PATCH] upstream: invalidate supplemental group cache used by
|
|
|
810d56 |
|
|
|
810d56 |
temporarily_use_uid() when the target uid differs; could cause failure to
|
|
|
810d56 |
read authorized_keys under some configurations. patch by Jakub Jelen via
|
|
|
810d56 |
bz2873; ok dtucker, markus
|
|
|
810d56 |
|
|
|
810d56 |
OpenBSD-Commit-ID: 48a345f0ee90f6c465a078eb5e89566b23abd8a1
|
|
|
810d56 |
---
|
|
|
810d56 |
uidswap.c | 8 ++++++--
|
|
|
810d56 |
1 file changed, 6 insertions(+), 2 deletions(-)
|
|
|
810d56 |
|
|
|
810d56 |
diff --git a/uidswap.c b/uidswap.c
|
|
|
810d56 |
index 8bf6b244e..1430b822a 100644
|
|
|
810d56 |
--- a/uidswap.c
|
|
|
810d56 |
+++ b/uidswap.c
|
|
|
810d56 |
@@ -49,6 +49,7 @@ static gid_t saved_egid = 0;
|
|
|
810d56 |
/* Saved effective uid. */
|
|
|
810d56 |
static int privileged = 0;
|
|
|
810d56 |
static int temporarily_use_uid_effective = 0;
|
|
|
810d56 |
+static uid_t user_groups_uid;
|
|
|
810d56 |
static gid_t *saved_egroups = NULL, *user_groups = NULL;
|
|
|
810d56 |
static int saved_egroupslen = -1, user_groupslen = -1;
|
|
|
810d56 |
|
|
|
810d56 |
@@ -92,10 +93,11 @@ temporarily_use_uid(struct passwd *pw)
|
|
|
810d56 |
fatal("getgroups: %.100s", strerror(errno));
|
|
|
810d56 |
} else { /* saved_egroupslen == 0 */
|
|
|
810d56 |
free(saved_egroups);
|
|
|
810d56 |
+ saved_egroups = NULL;
|
|
|
810d56 |
}
|
|
|
810d56 |
|
|
|
810d56 |
/* set and save the user's groups */
|
|
|
810d56 |
- if (user_groupslen == -1) {
|
|
|
810d56 |
+ if (user_groupslen == -1 || user_groups_uid != pw->pw_uid) {
|
|
|
810d56 |
if (initgroups(pw->pw_name, pw->pw_gid) < 0)
|
|
|
810d56 |
fatal("initgroups: %s: %.100s", pw->pw_name,
|
|
|
810d56 |
strerror(errno));
|
|
|
810d56 |
@@ -110,7 +112,9 @@ temporarily_use_uid(struct passwd *pw)
|
|
|
810d56 |
fatal("getgroups: %.100s", strerror(errno));
|
|
|
810d56 |
} else { /* user_groupslen == 0 */
|
|
|
810d56 |
free(user_groups);
|
|
|
810d56 |
+ user_groups = NULL;
|
|
|
810d56 |
}
|
|
|
810d56 |
+ user_groups_uid = pw->pw_uid;
|
|
|
810d56 |
}
|
|
|
810d56 |
/* Set the effective uid to the given (unprivileged) uid. */
|
|
|
810d56 |
if (setgroups(user_groupslen, user_groups) < 0)
|
|
|
810d56 |
|