From: Robert Swiecki Date: Thu, 19 Oct 2017 00:14:58 +0000 (+0200) Subject: user: avoid calling setresgid twice on machines that support setres(g|u)id32 X-Git-Tag: 2.1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=00fa26f696e922e9d0fe35cfd518db683febe260;p=platform%2Fupstream%2Fnsjail.git user: avoid calling setresgid twice on machines that support setres(g|u)id32 --- 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; }