setresuid.c 801 B

12345678910111213141516171819202122232425262728293031
  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 "syscalls.h"
  10. #include <unistd.h>
  11. #ifdef __NR_setresuid
  12. libc_hidden_proto(setresuid)
  13. #define __NR___syscall_setresuid __NR_setresuid
  14. static inline _syscall3(int, __syscall_setresuid,
  15. __kernel_uid_t, rgid, __kernel_uid_t, egid, __kernel_uid_t, sgid);
  16. int setresuid(uid_t ruid, uid_t euid, uid_t suid)
  17. {
  18. if (((ruid + 1) > (uid_t) ((__kernel_uid_t) - 1U))
  19. || ((euid + 1) > (uid_t) ((__kernel_uid_t) - 1U))
  20. || ((suid + 1) > (uid_t) ((__kernel_uid_t) - 1U))) {
  21. __set_errno(EINVAL);
  22. return -1;
  23. }
  24. return (__syscall_setresuid(ruid, euid, suid));
  25. }
  26. libc_hidden_def(setresuid)
  27. #endif