OSDN Git Service

Last portion of libc_hidden_proto removal.
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / common / seteuid.c
1 /*
2  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
3  *
4  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
5  */
6
7 #include <unistd.h>
8 #include <stdio.h>
9 #include <errno.h>
10 #include <pwd.h>
11 #include <sys/types.h>
12 #include <sys/syscall.h>
13
14 #if !defined __UCLIBC_LINUX_SPECIFIC__
15 #undef __NR_setresuid
16 #undef __NR_setresuid32
17 #endif
18
19 /* libc_hidden_proto(seteuid) */
20
21 #if (defined __NR_setresuid || defined __NR_setresuid32) && defined __USE_GNU
22 /* libc_hidden_proto(setresuid) */
23 #endif
24 /* libc_hidden_proto(setreuid) */
25
26 int seteuid(uid_t uid)
27 {
28     int result;
29
30     if (uid == (uid_t) ~0)
31     {
32         __set_errno (EINVAL);
33         return -1;
34     }
35
36 #if (defined __NR_setresuid || defined __NR_setresuid32) && defined __USE_GNU
37     result = setresuid(-1, uid, -1);
38     if (result == -1 && errno == ENOSYS)
39         /* Will also set the saved user ID if euid != uid,
40          * making it impossible to switch back...*/
41 #endif
42         result = setreuid(-1, uid);
43
44     return result;
45 }
46 libc_hidden_def(seteuid)