setresuid.c 719 B

123456789101112131415161718192021222324252627
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * setresuid() for uClibc
  4. *
  5. * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
  6. *
  7. * GNU Library General Public License (LGPL) version 2 or later.
  8. */
  9. #include "syscalls.h"
  10. #ifdef __NR_setresuid
  11. #define __NR___syscall_setresuid __NR_setresuid
  12. static inline _syscall3(int, __syscall_setresuid,
  13. __kernel_uid_t, rgid, __kernel_uid_t, egid, __kernel_uid_t, sgid);
  14. int setresuid(uid_t ruid, uid_t euid, uid_t suid)
  15. {
  16. if (((ruid + 1) > (uid_t) ((__kernel_uid_t) - 1U))
  17. || ((euid + 1) > (uid_t) ((__kernel_uid_t) - 1U))
  18. || ((suid + 1) > (uid_t) ((__kernel_uid_t) - 1U))) {
  19. __set_errno(EINVAL);
  20. return -1;
  21. }
  22. return (__syscall_setresuid(ruid, euid, suid));
  23. }
  24. #endif