From b136d6c6d3aa31771bc8b4645643570be1afc3e2 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Thu, 10 Nov 2016 14:51:24 +0800 Subject: [PATCH] Fix #938 --- src/utils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils.c b/src/utils.c index bebf0a45..a46cdb7c 100644 --- a/src/utils.c +++ b/src/utils.c @@ -109,14 +109,14 @@ run_as(const char *user) if (err == 0 && pwd) { /* setgid first, because we may not be allowed to do it anymore after setuid */ - if (setresgid(pwd->pw_gid, 0, pwd->pw_gid) != 0) { + if (setregid(pwd->pw_gid, 0) != 0) { LOGE( "Could not change group id to that of run_as user '%s': %s", user, strerror(errno)); return 0; } - if (setresuid(pwd->pw_uid, 0, pwd->pw_uid) != 0) { + if (setreuid(pwd->pw_uid, 0) != 0) { LOGE( "Could not change user id to that of run_as user '%s': %s", user, strerror(errno)); @@ -150,12 +150,12 @@ run_as(const char *user) return 0; } /* setgid first, because we may not allowed to do it anymore after setuid */ - if (setresgid(pwd->pw_gid, 0, pwd->pwd_gid) != 0) { + if (setregid(pwd->pw_gid, 0) != 0) { LOGE("Could not change group id to that of run_as user '%s': %s", user, strerror(errno)); return 0; } - if (setresuid(pwd->pw_uid, 0, pwd->pwd_uid) != 0) { + if (setresuid(pwd->pw_uid, 0) != 0) { LOGE("Could not change user id to that of run_as user '%s': %s", user, strerror(errno)); return 0;