diff options
-rw-r--r-- | uidswap.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: uidswap.c,v 1.37 2015/01/16 06:40:12 deraadt Exp $ */ | 1 | /* $OpenBSD: uidswap.c,v 1.38 2015/06/22 12:29:57 dtucker Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -113,7 +113,7 @@ temporarily_use_uid(struct passwd *pw) | |||
113 | } | 113 | } |
114 | } | 114 | } |
115 | /* Set the effective uid to the given (unprivileged) uid. */ | 115 | /* Set the effective uid to the given (unprivileged) uid. */ |
116 | if (setgroups(user_groupslen, user_groups) < 0) | 116 | if (user_groupslen > 0 && setgroups(user_groupslen, user_groups) < 0) |
117 | fatal("setgroups: %.100s", strerror(errno)); | 117 | fatal("setgroups: %.100s", strerror(errno)); |
118 | #ifndef SAVED_IDS_WORK_WITH_SETEUID | 118 | #ifndef SAVED_IDS_WORK_WITH_SETEUID |
119 | /* Propagate the privileged gid to all of our gids. */ | 119 | /* Propagate the privileged gid to all of our gids. */ |
@@ -187,7 +187,8 @@ restore_uid(void) | |||
187 | setgid(getgid()); | 187 | setgid(getgid()); |
188 | #endif /* SAVED_IDS_WORK_WITH_SETEUID */ | 188 | #endif /* SAVED_IDS_WORK_WITH_SETEUID */ |
189 | 189 | ||
190 | if (setgroups(saved_egroupslen, saved_egroups) < 0) | 190 | if (saved_egroupslen > 0 && |
191 | setgroups(saved_egroupslen, saved_egroups) < 0) | ||
191 | fatal("setgroups: %.100s", strerror(errno)); | 192 | fatal("setgroups: %.100s", strerror(errno)); |
192 | temporarily_use_uid_effective = 0; | 193 | temporarily_use_uid_effective = 0; |
193 | } | 194 | } |