From: Jan Safranek Date: Tue, 16 Nov 2010 11:11:35 +0000 (+0100) Subject: Use setresuid/setresgid to revoke suid/sgid bit X-Git-Tag: v0.37~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8f6dacd5fa923809b83512faf3c0e9d25625acc;p=thirdparty%2Flibcgroup.git Use setresuid/setresgid to revoke suid/sgid bit Use setresuid/setresgid to revoke suid/sgid bit instead of seteuid/setegid in cgexec. Signed-off-by: Jan Safranek Acked-by: Dhaval Giani Signed-off-by: Dhaval Giani --- diff --git a/src/tools/cgexec.c b/src/tools/cgexec.c index 7552fd98..8e0b4d8c 100644 --- a/src/tools/cgexec.c +++ b/src/tools/cgexec.c @@ -13,6 +13,10 @@ * */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + #include #include #include @@ -113,11 +117,11 @@ int main(int argc, char *argv[]) * socket, and an euid/egid should be changed to the executing user * from a root user. */ - if (seteuid(uid)) { + if (setresuid(uid, uid, uid)) { fprintf(stderr, "%s", strerror(errno)); return -1; } - if (setegid(gid)) { + if (setresgid(gid, gid, gid)) { fprintf(stderr, "%s", strerror(errno)); return -1; }