setresuid.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. _syscall3(int, setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
  16. libc_hidden_def(setresuid)
  17. #elif defined(__NR_setresuid)
  18. # define __NR___syscall_setresuid __NR_setresuid
  19. static __inline__ _syscall3(int, __syscall_setresuid,
  20. __kernel_uid_t, rgid, __kernel_uid_t, egid, __kernel_uid_t, sgid)
  21. int setresuid(uid_t ruid, uid_t euid, uid_t suid)
  22. {
  23. if (((ruid + 1) > (uid_t) ((__kernel_uid_t) - 1U))
  24. || ((euid + 1) > (uid_t) ((__kernel_uid_t) - 1U))
  25. || ((suid + 1) > (uid_t) ((__kernel_uid_t) - 1U))) {
  26. __set_errno(EINVAL);
  27. return -1;
  28. }
  29. return (__syscall_setresuid(ruid, euid, suid));
  30. }
  31. libc_hidden_def(setresuid)
  32. #endif
  33. #endif