yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame^] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
| 3 | * setresgid() for uClibc |
| 4 | * |
| 5 | * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> |
| 6 | * |
| 7 | * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. |
| 8 | */ |
| 9 | |
| 10 | #include <sys/syscall.h> |
| 11 | #ifdef __USE_GNU |
| 12 | #include <unistd.h> |
| 13 | |
| 14 | #if defined(__NR_setresgid32) |
| 15 | # undef __NR_setresgid |
| 16 | # define __NR_setresgid __NR_setresgid32 |
| 17 | |
| 18 | _syscall3(int, setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid) |
| 19 | libc_hidden_def(setresgid) |
| 20 | |
| 21 | #elif defined(__NR_setresgid) |
| 22 | |
| 23 | # define __NR___syscall_setresgid __NR_setresgid |
| 24 | static __inline__ _syscall3(int, __syscall_setresgid, |
| 25 | __kernel_gid_t, rgid, __kernel_gid_t, egid, __kernel_gid_t, sgid) |
| 26 | |
| 27 | int setresgid(gid_t rgid, gid_t egid, gid_t sgid) |
| 28 | { |
| 29 | if (((rgid + 1) > (gid_t) ((__kernel_gid_t) - 1U)) |
| 30 | || ((egid + 1) > (gid_t) ((__kernel_gid_t) - 1U)) |
| 31 | || ((sgid + 1) > (gid_t) ((__kernel_gid_t) - 1U))) { |
| 32 | __set_errno(EINVAL); |
| 33 | return -1; |
| 34 | } |
| 35 | return (__syscall_setresgid(rgid, egid, sgid)); |
| 36 | } |
| 37 | libc_hidden_def(setresgid) |
| 38 | |
| 39 | #endif |
| 40 | |
| 41 | #endif |