Unverified Commit 05bec191 by Christian Brauner Committed by Stéphane Graber

utils: use setres{u,g}id() in lxc_switch_uid_gid()

parent 9ae55948
...@@ -1336,7 +1336,7 @@ bool lxc_switch_uid_gid(uid_t uid, gid_t gid) ...@@ -1336,7 +1336,7 @@ bool lxc_switch_uid_gid(uid_t uid, gid_t gid)
int ret = 0; int ret = 0;
if (gid != LXC_INVALID_GID) { if (gid != LXC_INVALID_GID) {
ret = setgid(gid); ret = setresgid(gid, gid, gid);
if (ret < 0) { if (ret < 0) {
SYSERROR("Failed to switch to gid %d", gid); SYSERROR("Failed to switch to gid %d", gid);
return false; return false;
...@@ -1345,7 +1345,7 @@ bool lxc_switch_uid_gid(uid_t uid, gid_t gid) ...@@ -1345,7 +1345,7 @@ bool lxc_switch_uid_gid(uid_t uid, gid_t gid)
} }
if (uid != LXC_INVALID_UID) { if (uid != LXC_INVALID_UID) {
ret = setuid(uid); ret = setresuid(uid, uid, uid);
if (ret < 0) { if (ret < 0) {
SYSERROR("Failed to switch to uid %d", uid); SYSERROR("Failed to switch to uid %d", uid);
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment