From 00fa26f696e922e9d0fe35cfd518db683febe260 Mon Sep 17 00:00:00 2001 From: Robert Swiecki Date: Thu, 19 Oct 2017 02:14:58 +0200 Subject: [PATCH] user: avoid calling setresgid twice on machines that support setres(g|u)id32 --- user.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/user.c b/user.c index 68dac55..bd063e7 100644 --- a/user.c +++ b/user.c @@ -48,16 +48,16 @@ static bool userSetResGid(gid_t gid) { LOG_D("setresgid(%d)", gid); #if defined(__NR_setresgid32) - if (syscall(__NR_setresgid32, (uintptr_t)gid, (uintptr_t)gid, (uintptr_t)gid) == -1 - && errno != ENOSYS) { + if (syscall(__NR_setresgid32, (uintptr_t)gid, (uintptr_t)gid, (uintptr_t)gid) == -1) { PLOG_W("setresgid32(%d)", (int)gid); return false; } -#endif /* defined(__NR_setresgid32) */ +#else /* defined(__NR_setresgid32) */ if (syscall(__NR_setresgid, (uintptr_t)gid, (uintptr_t)gid, (uintptr_t)gid) == -1) { PLOG_W("setresgid(%d)", gid); return false; } +#endif /* defined(__NR_setresuid32) */ return true; } @@ -65,16 +65,16 @@ static bool userSetResUid(uid_t uid) { LOG_D("setresuid(%d)", uid); #if defined(__NR_setresuid32) - if (syscall(__NR_setresuid32, (uintptr_t)uid, (uintptr_t)uid, (uintptr_t)uid) == -1 - && errno != ENOSYS) { + if (syscall(__NR_setresuid32, (uintptr_t)uid, (uintptr_t)uid, (uintptr_t)uid) == -1) { PLOG_W("setresuid32(%d)", (int)uid); return false; } -#endif /* defined(__NR_setresuid32) */ +#else /* defined(__NR_setresuid32) */ if (syscall(__NR_setresuid, (uintptr_t)uid, (uintptr_t)uid, (uintptr_t)uid) == -1) { PLOG_W("setresuid(%d)", uid); return false; } +#endif /* defined(__NR_setresuid32) */ return true; } -- 2.34.1