setresuid.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * setresuid() 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. #include <sys/syscall.h>
  10. #if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
  11. #include <unistd.h>
  12. #if defined(__NR_setresuid32)
  13. # undef __NR_setresuid
  14. # define __NR_setresuid __NR_setresuid32
  15. /* libc_hidden_proto(setresuid) */
  16. _syscall3(int, setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
  17. libc_hidden_def(setresuid)
  18. #elif defined(__NR_setresuid)
  19. # define __NR___syscall_setresuid __NR_setresuid
  20. static __inline__ _syscall3(int, __syscall_setresuid,
  21. __kernel_uid_t, rgid, __kernel_uid_t, egid, __kernel_uid_t, sgid)
  22. /* libc_hidden_proto(setresuid) */
  23. int setresuid(uid_t ruid, uid_t euid, uid_t suid)
  24. {
  25. if (((ruid + 1) > (uid_t) ((__kernel_uid_t) - 1U))
  26. || ((euid + 1) > (uid_t) ((__kernel_uid_t) - 1U))
  27. || ((suid + 1) > (uid_t) ((__kernel_uid_t) - 1U))) {
  28. __set_errno(EINVAL);
  29. return -1;
  30. }
  31. return (__syscall_setresuid(ruid, euid, suid));
  32. }
  33. libc_hidden_def(setresuid)
  34. #endif
  35. #endif