aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/i386
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-10-16 16:33:36 +0000
committerUlrich Drepper <drepper@redhat.com>1998-10-16 16:33:36 +0000
commit9ffbb61221fd5d0ee2b7989d2e5c785efee8cc02 (patch)
tree5c9b303b79c188e0f33571a09c2975ae8eb0e3ce /sysdeps/unix/sysv/linux/i386
parent39e4f7f84ec269a2d86a060d417ceaeb21f53305 (diff)
downloadglibc-9ffbb61221fd5d0ee2b7989d2e5c785efee8cc02.tar
glibc-9ffbb61221fd5d0ee2b7989d2e5c785efee8cc02.tar.gz
glibc-9ffbb61221fd5d0ee2b7989d2e5c785efee8cc02.tar.bz2
glibc-9ffbb61221fd5d0ee2b7989d2e5c785efee8cc02.zip
Update.
* sysdeps/unix/opendir.c: Use O_DIRECTORY if available. If not available double check to verify it's a directory. * sysdeps/unix/sysv/linux/alpha/bits/fcntl.h: Add O_DIRECTORY. * sysdeps/unix/sysv/linux/mips/bits/fcntl: Likewise. * sysdeps/unix/sysv/linux/bits/fcntl.h: Remove O_* constants which are not generally available. * sysdeps/unix/sysv/linux/i386/bits/fcntl.h: New file. * sysdeps/unix/sysv/linux/i386/setgroups.c: Add range check for values. * sysdeps/unix/sysv/linux/arm/Makefile: New file. * sysdeps/unix/sysv/linux/arm/setegid.c: New file. * sysdeps/unix/sysv/linux/arm/seteuid.c: New file. * sysdeps/unix/sysv/linux/arm/setfsgid.c: New file. * sysdeps/unix/sysv/linux/arm/setfsuid.c: New file. * sysdeps/unix/sysv/linux/arm/setgid.c: New file. * sysdeps/unix/sysv/linux/arm/setgroups.c: New file. * sysdeps/unix/sysv/linux/arm/setresgid.c: New file. * sysdeps/unix/sysv/linux/arm/setresuid.c: New file. * sysdeps/unix/sysv/linux/arm/setuid.c: New file. * sysdeps/unix/sysv/linux/i386/setegid.c: New file. * sysdeps/unix/sysv/linux/i386/seteuid.c: New file. * sysdeps/unix/sysv/linux/i386/setfsgid.c: New file. * sysdeps/unix/sysv/linux/i386/setfsuid.c: New file. * sysdeps/unix/sysv/linux/i386/setgid.c: New file. * sysdeps/unix/sysv/linux/i386/setgroups.c: New file. * sysdeps/unix/sysv/linux/i386/setresgid.c: New file. * sysdeps/unix/sysv/linux/i386/setresuid.c: New file. * sysdeps/unix/sysv/linux/i386/setuid.c: New file. * sysdeps/unix/sysv/linux/m68k/setegid.c: New file. * sysdeps/unix/sysv/linux/m68k/seteuid.c: New file. * sysdeps/unix/sysv/linux/m68k/setfsgid.c: New file. * sysdeps/unix/sysv/linux/m68k/setfsuid.c: New file. * sysdeps/unix/sysv/linux/m68k/setgid.c: New file. * sysdeps/unix/sysv/linux/m68k/setgroups.c: New file. * sysdeps/unix/sysv/linux/m68k/setresgid.c: New file. * sysdeps/unix/sysv/linux/m68k/setresuid.c: New file. * sysdeps/unix/sysv/linux/m68k/setuid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setegid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/seteuid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setfsgid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setfsuid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setgid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setgroups.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setresgid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setresuid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setuid.c: New file. * sysdeps/unix/sysv/linux/arm/syscalls.list: Add s_setgid, s_setresuid, s_setresgid, and s_setuid. * sysdeps/unix/sysv/linux/i386/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/m68k/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/i386/Makefile [subdir=misc] (sysdep_routines): Add setfsgid, setfsuid, setresgid, and setresuid. * sysdeps/unix/sysv/linux/m68k/Makefile: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/Makefile: Likewise. 1998-10-16 Ulrich Drepper <drepper@cygnus.com> * iconv/skeleton.c: Include ELF header only of STATIC_GCONV is not
Diffstat (limited to 'sysdeps/unix/sysv/linux/i386')
-rw-r--r--sysdeps/unix/sysv/linux/i386/Makefile3
-rw-r--r--sysdeps/unix/sysv/linux/i386/bits/fcntl.h138
-rw-r--r--sysdeps/unix/sysv/linux/i386/setegid.c37
-rw-r--r--sysdeps/unix/sysv/linux/i386/seteuid.c53
-rw-r--r--sysdeps/unix/sysv/linux/i386/setfsgid.c47
-rw-r--r--sysdeps/unix/sysv/linux/i386/setfsuid.c47
-rw-r--r--sysdeps/unix/sysv/linux/i386/setgid.c40
-rw-r--r--sysdeps/unix/sysv/linux/i386/setgroups.c12
-rw-r--r--sysdeps/unix/sysv/linux/i386/setresgid.c46
-rw-r--r--sysdeps/unix/sysv/linux/i386/setresuid.c47
-rw-r--r--sysdeps/unix/sysv/linux/i386/setuid.c40
-rw-r--r--sysdeps/unix/sysv/linux/i386/syscalls.list6
12 files changed, 513 insertions, 3 deletions
diff --git a/sysdeps/unix/sysv/linux/i386/Makefile b/sysdeps/unix/sysv/linux/i386/Makefile
index c27f390b59..29011fd22e 100644
--- a/sysdeps/unix/sysv/linux/i386/Makefile
+++ b/sysdeps/unix/sysv/linux/i386/Makefile
@@ -1,5 +1,6 @@
ifeq ($(subdir),misc)
-sysdep_routines += ioperm iopl vm86 s_pread64 s_pwrite64
+sysdep_routines += ioperm iopl vm86 s_pread64 s_pwrite64 setfsgid setfsuid \
+ setresgid setresuid
sysdep_headers += sys/elf.h sys/perm.h sys/reg.h sys/vm86.h sys/debugreg.h
endif
diff --git a/sysdeps/unix/sysv/linux/i386/bits/fcntl.h b/sysdeps/unix/sysv/linux/i386/bits/fcntl.h
new file mode 100644
index 0000000000..0c8afd22fa
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/bits/fcntl.h
@@ -0,0 +1,138 @@
+/* O_*, F_*, FD_* bit values for Linux.
+ Copyright (C) 1995, 1996, 1997, 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. */
+
+#ifndef _FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+
+#include <sys/types.h>
+
+/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
+ located on an ext2 file system */
+#define O_ACCMODE 0003
+#define O_RDONLY 00
+#define O_WRONLY 01
+#define O_RDWR 02
+#define O_CREAT 0100 /* not fcntl */
+#define O_EXCL 0200 /* not fcntl */
+#define O_NOCTTY 0400 /* not fcntl */
+#define O_TRUNC 01000 /* not fcntl */
+#define O_APPEND 02000
+#define O_NONBLOCK 04000
+#define O_NDELAY O_NONBLOCK
+#define O_SYNC 010000
+#define O_FSYNC O_SYNC
+#define O_ASYNC 020000
+
+#ifdef __USE_GNU
+# define O_DIRECT 040000 /* Direct disk access. */
+# define O_DIRECTORY 0200000 /* Must be a directory. */
+#endif
+
+/* For now Linux has synchronisity options for data and read operations.
+ We define the symbols here but let them do the same as O_SYNC since
+ this is a superset. */
+#if defined __USE_POSIX199309 || defined __USE_UNIX98
+# define O_DSYNC O_SYNC /* Synchronize data. */
+# define O_RSYNC O_SYNC /* Synchronize read operations. */
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define O_LARGEFILE 0100000
+#endif
+
+/* Values for the second argument to `fcntl'. */
+#define F_DUPFD 0 /* Duplicate file descriptor. */
+#define F_GETFD 1 /* Get file descriptor flags. */
+#define F_SETFD 2 /* Set file descriptor flags. */
+#define F_GETFL 3 /* Get file status flags. */
+#define F_SETFL 4 /* Set file status flags. */
+#define F_GETLK 5 /* Get record locking info. */
+#define F_SETLK 6 /* Set record locking info (non-blocking). */
+#define F_SETLKW 7 /* Set record locking info (blocking). */
+
+/* XXX missing */
+#define F_GETLK64 5 /* Get record locking info. */
+#define F_SETLK64 6 /* Set record locking info (non-blocking). */
+#define F_SETLKW64 7 /* Set record locking info (blocking). */
+
+#ifdef __USE_BSD
+# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */
+# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETSIG 10 /* Set number of signal to be sent. */
+# define F_GETSIG 11 /* Get number of signal to be sent. */
+#endif
+
+/* For F_[GET|SET]FL. */
+#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
+
+/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
+#define F_RDLCK 0 /* Read lock. */
+#define F_WRLCK 1 /* Write lock. */
+#define F_UNLCK 2 /* Remove lock. */
+
+/* for old implementation of bsd flock () */
+#define F_EXLCK 4 /* or 3 */
+#define F_SHLCK 8 /* or 4 */
+
+/* operations for bsd flock(), also used by the kernel implementation */
+#define LOCK_SH 1 /* shared lock */
+#define LOCK_EX 2 /* exclusive lock */
+#define LOCK_NB 4 /* or'd with one of the above to prevent
+ blocking */
+#define LOCK_UN 8 /* remove lock */
+
+struct flock
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+#ifndef __USE_FILE_OFFSET64
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+#else
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+#endif
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+
+#ifdef __USE_LARGEFILE64
+struct flock64
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+#endif
+
+/* Define some more compatibility macros to be backward compatible with
+ BSD systems which did not managed to hide these kernel macros. */
+#ifdef __USE_BSD
+# define FAPPEND O_APPEND
+# define FFSYNC O_FSYNC
+# define FASYNC O_ASYNC
+# define FNONBLOCK O_NONBLOCK
+# define FNDELAY O_NDELAY
+#endif /* Use BSD. */
diff --git a/sysdeps/unix/sysv/linux/i386/setegid.c b/sysdeps/unix/sysv/linux/i386/setegid.c
new file mode 100644
index 0000000000..e29d2eab7b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/setegid.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1995, 1996, 1997, 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 <unistd.h>
+#include <sys/types.h>
+
+#include <linux/posix_types.h>
+
+int
+setegid (gid)
+ gid_t gid;
+{
+ if (gid == (gid_t) ~0
+ || gid != (gid_t) ((__kernel_gid_t) gid))
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return __setregid (-1, gid);
+}
diff --git a/sysdeps/unix/sysv/linux/i386/seteuid.c b/sysdeps/unix/sysv/linux/i386/seteuid.c
new file mode 100644
index 0000000000..e82ecc36e9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/seteuid.c
@@ -0,0 +1,53 @@
+/* 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>
+
+#include <linux/posix_types.h>
+
+#ifdef __NR_setresuid
+extern int __setresuid (uid_t ruid, uid_t euid, uid_t suid);
+#endif
+
+int
+seteuid (uid_t uid)
+{
+ int result;
+
+ if (uid == (uid_t) ~0
+ || uid != (uid_t) ((__kernel_uid_t) uid))
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ /* First try the syscall. */
+#ifdef __NR_setresuid
+ result = __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. */
+#endif
+ result = __setreuid (-1, uid);
+
+ return result;
+}
diff --git a/sysdeps/unix/sysv/linux/i386/setfsgid.c b/sysdeps/unix/sysv/linux/i386/setfsgid.c
new file mode 100644
index 0000000000..4af26f554d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/setfsgid.c
@@ -0,0 +1,47 @@
+/* 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>
+
+#include <linux/posix_types.h>
+
+#ifdef __NR_setfsgid
+extern int __syscall_setfsgid (__kernel_gid_t);
+
+int
+setfsgid (gid_t gid)
+{
+ if (gid != (gid_t) ((__kernel_gid_t) gid))
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return __syscall_setfsgid (gid);
+}
+#else
+int
+setfsgid (gid_t gid)
+{
+ __set_errno (ENOSYS);
+ return -1;
+}
+#endif
diff --git a/sysdeps/unix/sysv/linux/i386/setfsuid.c b/sysdeps/unix/sysv/linux/i386/setfsuid.c
new file mode 100644
index 0000000000..5133dc0045
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/setfsuid.c
@@ -0,0 +1,47 @@
+/* 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>
+
+#include <linux/posix_types.h>
+
+#ifdef __NR_setfsuid
+extern int __syscall_setfsuid (__kernel_uid_t);
+
+int
+setfsuid (uid_t uid)
+{
+ if (uid != (uid_t) ((__kernel_uid_t) uid))
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return __syscall_setfsuid (uid);
+}
+#else
+int
+setfsuid (uid_t uid)
+{
+ __set_errno (ENOSYS);
+ return -1;
+}
+#endif
diff --git a/sysdeps/unix/sysv/linux/i386/setgid.c b/sysdeps/unix/sysv/linux/i386/setgid.c
new file mode 100644
index 0000000000..87fbd74e05
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/setgid.c
@@ -0,0 +1,40 @@
+/* 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>
+
+#include <linux/posix_types.h>
+
+extern int __syscall_setgid (__kernel_gid_t);
+
+int
+__setgid (gid_t gid)
+{
+ if (gid == (gid_t) ~0
+ || gid != (gid_t) ((__kernel_gid_t) gid))
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return __syscall_setgid (gid);
+}
+weak_alias (__setgid, setgid)
diff --git a/sysdeps/unix/sysv/linux/i386/setgroups.c b/sysdeps/unix/sysv/linux/i386/setgroups.c
index 8f8711913e..38e62a8217 100644
--- a/sysdeps/unix/sysv/linux/i386/setgroups.c
+++ b/sysdeps/unix/sysv/linux/i386/setgroups.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 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
@@ -16,6 +16,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#include <grp.h>
@@ -36,6 +37,13 @@ setgroups (n, groups)
__kernel_gid_t kernel_groups[n];
for (i = 0; i < n; i++)
- kernel_groups[i] = groups[i];
+ {
+ kernel_groups[i] = groups[i];
+ if (groups[i] != (gid_t) ((__kernel_gid_t) groups[i]))
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+ }
return __syscall_setgroups (n, kernel_groups);
}
diff --git a/sysdeps/unix/sysv/linux/i386/setresgid.c b/sysdeps/unix/sysv/linux/i386/setresgid.c
new file mode 100644
index 0000000000..82d967b39b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/setresgid.c
@@ -0,0 +1,46 @@
+/* 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 <unistd.h>
+#include <sys/types.h>
+
+#include <linux/posix_types.h>
+
+#include <sys/syscall.h>
+#ifdef __NR_setresgid
+
+extern int __syscall_setresgid (__kernel_gid_t rgid, __kernel_gid_t egid,
+ __kernel_gid_t sgid);
+
+int
+setresgid (gid_t rgid, gid_t egid, gid_t sgid)
+{
+ if ((rgid != (gid_t) ((__kernel_gid_t) rgid))
+ || (egid != (gid_t) ((__kernel_gid_t) egid))
+ || (sgid != (gid_t) ((__kernel_gid_t) sgid)))
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return __syscall_setresgid (rgid, egid, sgid);
+}
+#else
+# include <sysdeps/generic/setresgid.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/i386/setresuid.c b/sysdeps/unix/sysv/linux/i386/setresuid.c
new file mode 100644
index 0000000000..db8a44fb61
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/setresuid.c
@@ -0,0 +1,47 @@
+/* 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 <unistd.h>
+#include <sys/types.h>
+
+#include <linux/posix_types.h>
+
+#include <sys/syscall.h>
+#ifdef __NR_setresuid
+
+extern int __syscall_setresuid (__kernel_uid_t rgid, __kernel_uid_t egid,
+ __kernel_uid_t sgid);
+
+int
+__setresuid (gid_t ruid, gid_t euid, gid_t suid)
+{
+ if ((ruid != (uid_t) ((__kernel_uid_t) ruid))
+ || (euid != (uid_t) ((__kernel_uid_t) euid))
+ || (suid != (uid_t) ((__kernel_uid_t) suid)))
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return __syscall_setresuid (ruid, euid, suid);
+}
+weak_alias (__setresuid, setresuid)
+#else
+# include <sysdeps/generic/setresuid.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/i386/setuid.c b/sysdeps/unix/sysv/linux/i386/setuid.c
new file mode 100644
index 0000000000..3379114384
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/setuid.c
@@ -0,0 +1,40 @@
+/* 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>
+
+#include <linux/posix_types.h>
+
+extern int __syscall_setuid (__kernel_uid_t);
+
+int
+__setuid (uid_t uid)
+{
+ if (uid == (uid_t) ~0
+ || uid != (uid_t) ((__kernel_uid_t) uid))
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return __syscall_setuid (uid);
+}
+weak_alias (__setuid, setuid)
diff --git a/sysdeps/unix/sysv/linux/i386/syscalls.list b/sysdeps/unix/sysv/linux/i386/syscalls.list
index 2c167b9bdd..e02c5cffce 100644
--- a/sysdeps/unix/sysv/linux/i386/syscalls.list
+++ b/sysdeps/unix/sysv/linux/i386/syscalls.list
@@ -4,5 +4,11 @@ modify_ldt EXTRA modify_ldt 3 __modify_ldt modify_ldt
s_chown chown chown 3 __syscall_chown
s_getgroups getgroups getgroups 2 __syscall_getgroups
s_llseek llseek _llseek 5 __sys_llseek
+s_setfsgid setfsgid setfsgid 1 __syscall_setfsgid
+s_setfsuid setfsuid setfsuid 1 __syscall_setfsuid
+s_setgid setgid setgid 1 __syscall_setgid
s_setgroups setgroups setgroups 2 __syscall_setgroups
+s_setresgid setresgid setresgid 3 __syscall_setresgid
+s_setresuid setresuid setresuid 3 __syscall_setresuid
+s_setuid setuid setuid 1 __syscall_setuid
vm86 - vm86 1 __vm86 vm86