setresuid.c 1020 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * setresuid() for uClibc
  3. *
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <sys/syscall.h>
  9. #if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
  10. #include <unistd.h>
  11. #if defined(__NR_setresuid32)
  12. # undef __NR_setresuid
  13. # define __NR_setresuid __NR_setresuid32
  14. _syscall3(int, setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
  15. libc_hidden_weak(setresuid)
  16. #elif defined(__NR_setresuid)
  17. # define __NR___syscall_setresuid __NR_setresuid
  18. static __inline__ _syscall3(int, __syscall_setresuid,
  19. __kernel_uid_t, rgid, __kernel_uid_t, egid, __kernel_uid_t, sgid)
  20. int setresuid(uid_t ruid, uid_t euid, uid_t suid)
  21. {
  22. if (((ruid + 1) > (uid_t) ((__kernel_uid_t) - 1U))
  23. || ((euid + 1) > (uid_t) ((__kernel_uid_t) - 1U))
  24. || ((suid + 1) > (uid_t) ((__kernel_uid_t) - 1U))) {
  25. __set_errno(EINVAL);
  26. return -1;
  27. }
  28. return (__syscall_setresuid(ruid, euid, suid));
  29. }
  30. libc_hidden_weak(setresuid)
  31. #endif
  32. #endif