Skip to content

Commit

Permalink
utils: use setres{u,g}id() in lxc_switch_uid_gid()
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner authored and stgraber committed Apr 2, 2020
1 parent 9ae5594 commit 05bec19
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lxc/utils.c
Expand Up @@ -1336,7 +1336,7 @@ bool lxc_switch_uid_gid(uid_t uid, gid_t gid)
int ret = 0;

if (gid != LXC_INVALID_GID) {
ret = setgid(gid);
ret = setresgid(gid, gid, gid);
if (ret < 0) {
SYSERROR("Failed to switch to gid %d", gid);
return false;
Expand All @@ -1345,7 +1345,7 @@ bool lxc_switch_uid_gid(uid_t uid, gid_t gid)
}

if (uid != LXC_INVALID_UID) {
ret = setuid(uid);
ret = setresuid(uid, uid, uid);
if (ret < 0) {
SYSERROR("Failed to switch to uid %d", uid);
return false;
Expand Down

0 comments on commit 05bec19

Please sign in to comment.