diff options
Diffstat (limited to 'sysdeps/unix/sysv/linux')
-rw-r--r-- | sysdeps/unix/sysv/linux/Makefile | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/seteuid.c | 52 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/syscalls.list | 2 |
3 files changed, 53 insertions, 3 deletions
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 7de1008716..af53184cb2 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -9,7 +9,7 @@ CPPFLAGS += -DHAVE_LLSEEK=1 endif ifeq ($(subdir),misc) -sysdep_routines += sysctl clone llseek getresuid getresgid +sysdep_routines += sysctl clone llseek getresuid getresgid sys_setresuid sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h sys/mtio.h \ sys/io.h sys/klog.h sys/kdaemon.h \ diff --git a/sysdeps/unix/sysv/linux/seteuid.c b/sysdeps/unix/sysv/linux/seteuid.c index 37fb72c020..c8e3950cfa 100644 --- a/sysdeps/unix/sysv/linux/seteuid.c +++ b/sysdeps/unix/sysv/linux/seteuid.c @@ -1 +1,51 @@ -#include <sysdeps/unix/bsd/seteuid.c> +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <sys/syscall.h> +#include <sys/types.h> +#include <unistd.h> + +#ifdef __NR_setresuid + +extern int __syscall_setresuid (uid_t ruid, uid_t euid, uid_t suid); + +int +seteuid (uid_t uid) +{ + int result; + + if (uid == (uid_t) ~0) + { + __set_errno (EINVAL); + return -1; + } + + /* First try the syscall. */ + result = __syscall_setresuid (-1, uid, -1); + if (result == -1 && errno == ENOSYS) + /* No system call available. Use emulation. This may not work + since `setreuid' also sets the saved user ID when UID is not + equal to the real user ID, making it impossible to switch back. */ + result = __setreuid (-1, uid); + + return result; +} +#else +# include <sysdeps/unix/bsd/seteuid.c> +#endif diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index e80fd84568..6d06d0df99 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -71,12 +71,12 @@ setfsgid EXTRA setfsgid 1 setfsgid setfsuid EXTRA setfsuid 1 setfsuid setpgid - setpgid 2 __setpgid setpgid setresgid EXTRA setresgid 3 setresgid -setresuid EXTRA setresuid 3 setresuid sigaltstack - sigaltstack 2 __sigaltstack sigaltstack sys_fstat fxstat fstat 2 __syscall_fstat sys_lstat lxstat lstat 2 __syscall_lstat sys_mknod xmknod mknod 3 __syscall_mknod sys_readv readv readv 3 __syscall_readv +sys_setresuid EXTRA setresuid 3 __syscall_setresuid sys_stat xstat stat 2 __syscall_stat sys_writev writev writev 3 __syscall_writev sysinfo EXTRA sysinfo 1 sysinfo |