Use setresuid/setresgid to revoke suid/sgid bit instead of seteuid/setegid
in cgexec.
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
*
*/
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
#include <errno.h>
#include <grp.h>
#include <libcgroup.h>
* 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;
}