diff options
author | Ulrich Drepper <drepper@redhat.com> | 1998-10-16 16:33:36 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1998-10-16 16:33:36 +0000 |
commit | 9ffbb61221fd5d0ee2b7989d2e5c785efee8cc02 (patch) | |
tree | 5c9b303b79c188e0f33571a09c2975ae8eb0e3ce /sysdeps | |
parent | 39e4f7f84ec269a2d86a060d417ceaeb21f53305 (diff) | |
download | glibc-9ffbb61221fd5d0ee2b7989d2e5c785efee8cc02.tar.gz glibc-9ffbb61221fd5d0ee2b7989d2e5c785efee8cc02.tar.xz 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')
39 files changed, 584 insertions, 14 deletions
diff --git a/sysdeps/unix/opendir.c b/sysdeps/unix/opendir.c index 77f2a0a490..657ad176a8 100644 --- a/sysdeps/unix/opendir.c +++ b/sysdeps/unix/opendir.c @@ -29,6 +29,30 @@ #include <dirstream.h> + +/* We want to be really safe the file we opened is a directory. Some systems + have support for this, others don't. */ +#ifdef O_DIRECTORY +# define OPENDIR(NAME) \ + do { \ + fd = __open (NAME, O_RDONLY|O_NDELAY|O_DIRECTORY); \ + if (fd < 0) \ + return NULL; \ + } while (0) +#else +# define OPENDIR(NAME) \ + do { \ + fd = __open (NAME, O_RDONLY|O_NDELAY); \ + if (fd < 0 || __fstat (fd, &statbuf) < 0 || ! S_ISDIR (statbuf.st_mode)) \ + { \ + if (fd >= 0) \ + __close (fd); \ + return NULL; \ + } \ + } while (0) +#endif + + /* Open a directory stream on NAME. */ DIR * __opendir (const char *name) @@ -58,9 +82,7 @@ __opendir (const char *name) return NULL; } - fd = __open (name, O_RDONLY|O_NDELAY); - if (fd < 0) - return NULL; + OPENDIR (name); if (__fcntl (fd, F_SETFD, FD_CLOEXEC) < 0) goto lose; diff --git a/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h b/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h index 7cd32a34a3..e67ad19f65 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h @@ -45,6 +45,7 @@ #ifdef __USE_GNU # define O_DIRECT 040000 /* Direct disk access. */ +# define O_DIRECTORY 0100000 /* Must be a directory. */ #endif /* Not necessary, files are always with 64bit off_t. */ diff --git a/sysdeps/unix/sysv/linux/arm/Makefile b/sysdeps/unix/sysv/linux/arm/Makefile new file mode 100644 index 0000000000..e65a5c1fa3 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/Makefile @@ -0,0 +1,3 @@ +ifeq ($(subdir),misc) +sysdep_routines += setfsgid setfsuid setresgid setresuid +endif diff --git a/sysdeps/unix/sysv/linux/arm/setegid.c b/sysdeps/unix/sysv/linux/arm/setegid.c new file mode 100644 index 0000000000..2e3a54c893 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/setegid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/setegid.c> diff --git a/sysdeps/unix/sysv/linux/arm/seteuid.c b/sysdeps/unix/sysv/linux/arm/seteuid.c new file mode 100644 index 0000000000..18e41d08c1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/seteuid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/seteuid.c> diff --git a/sysdeps/unix/sysv/linux/arm/setfsgid.c b/sysdeps/unix/sysv/linux/arm/setfsgid.c new file mode 100644 index 0000000000..0886712569 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/setfsgid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/setfsgid.c> diff --git a/sysdeps/unix/sysv/linux/arm/setfsuid.c b/sysdeps/unix/sysv/linux/arm/setfsuid.c new file mode 100644 index 0000000000..a9f22eb8ab --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/setfsuid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/setfsuid.c> diff --git a/sysdeps/unix/sysv/linux/arm/setgid.c b/sysdeps/unix/sysv/linux/arm/setgid.c new file mode 100644 index 0000000000..377021d9ec --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/setgid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/setgid.c> diff --git a/sysdeps/unix/sysv/linux/arm/setgroups.c b/sysdeps/unix/sysv/linux/arm/setgroups.c new file mode 100644 index 0000000000..0e7086278f --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/setgroups.c @@ -0,0 +1,2 @@ +/* We also have to rewrite the kernel gid_t to the user land type. */ +#include <sysdeps/unix/sysv/linux/i386/setgroups.c> diff --git a/sysdeps/unix/sysv/linux/arm/setresgid.c b/sysdeps/unix/sysv/linux/arm/setresgid.c new file mode 100644 index 0000000000..daca1a4833 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/setresgid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/setresgid.c> diff --git a/sysdeps/unix/sysv/linux/arm/setresuid.c b/sysdeps/unix/sysv/linux/arm/setresuid.c new file mode 100644 index 0000000000..3aeabe9ad7 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/setresuid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/setresuid.c> diff --git a/sysdeps/unix/sysv/linux/arm/setuid.c b/sysdeps/unix/sysv/linux/arm/setuid.c new file mode 100644 index 0000000000..de394379be --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/setuid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/setuid.c> diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list index a3ecdd7d73..3adc087d15 100644 --- a/sysdeps/unix/sysv/linux/arm/syscalls.list +++ b/sysdeps/unix/sysv/linux/arm/syscalls.list @@ -2,6 +2,10 @@ s_getgroups getgroups getgroups 2 __syscall_getgroups s_llseek llseek _llseek 5 __sys_llseek +s_setgid setgid setgid 1 __syscall_setgid s_setgroups setgroups setgroups 2 __syscall_setgroups +s_setresuid setresuid setresuid 3 __syscall_setresuid +s_setresgid setresgid setresgid 3 __syscall_setresgid +s_setuid setuid setuid 1 __syscall_setuid vm86 - vm86 1 __vm86 vm86 syscall - syscall 5 syscall diff --git a/sysdeps/unix/sysv/linux/bits/fcntl.h b/sysdeps/unix/sysv/linux/bits/fcntl.h index c2a8ee91ac..42ad79f6ab 100644 --- a/sysdeps/unix/sysv/linux/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/bits/fcntl.h @@ -42,7 +42,7 @@ #define O_ASYNC 020000 #ifdef __USE_GNU -# define O_DIRECT 040000 /* Direct disk access. */ +# define O_DIRECTORY 040000 /* Must be a directory. */ #endif /* For now Linux has synchronisity options for data and read operations. @@ -53,10 +53,6 @@ # 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. */ 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 diff --git a/sysdeps/unix/sysv/linux/m68k/Makefile b/sysdeps/unix/sysv/linux/m68k/Makefile index 71cee22442..7e46d51b86 100644 --- a/sysdeps/unix/sysv/linux/m68k/Makefile +++ b/sysdeps/unix/sysv/linux/m68k/Makefile @@ -3,7 +3,7 @@ m68k-syntax-flag = -DMOTOROLA_SYNTAX ifeq ($(subdir),misc) -sysdep_routines += mremap +sysdep_routines += mremap setfsgid setfsuid setresgid setresuid sysdep_headers += sys/reg.h endif diff --git a/sysdeps/unix/sysv/linux/m68k/syscalls.list b/sysdeps/unix/sysv/linux/m68k/syscalls.list index 473c2ec5b2..971c4ee7bf 100644 --- a/sysdeps/unix/sysv/linux/m68k/syscalls.list +++ b/sysdeps/unix/sysv/linux/m68k/syscalls.list @@ -4,4 +4,8 @@ cacheflush EXTRA cacheflush 4 __cacheflush cacheflush s_getgroups getgroups getgroups 2 __syscall_getgroups s_llseek llseek _llseek 5 __sys_llseek +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 diff --git a/sysdeps/unix/sysv/linux/mips/bits/fcntl.h b/sysdeps/unix/sysv/linux/mips/bits/fcntl.h index 0a0d9c9d00..63e754d5fe 100644 --- a/sysdeps/unix/sysv/linux/mips/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/mips/bits/fcntl.h @@ -38,7 +38,11 @@ #define O_EXCL 0x0400 /* not fcntl */ #define O_NOCTTY 0x0800 /* not fcntl */ #define O_FSYNC O_SYNC -#define O_ASYNC 020000 +#define O_ASYNC 0x1000 + +#ifdef __USE_GNU +# define O_DIRECTORY 0x2000 /* Must be a directory. */ +#endif #define O_NDELAY O_NONBLOCK diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile b/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile index 016290646a..5ba1ccdc62 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile @@ -1,6 +1,10 @@ asm-CPPFLAGS=-D__ASSEMBLY__ ASFLAGS-.os=-fPIC +ifeq ($(subdir),misc) +sysdep_routines += setfsgid setfsuid setresgid setresuid +endif + # When I get this to work, this is the right thing ifeq ($(subdir),elf) CFLAGS-rtld.c += -mv8 diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/setegid.c b/sysdeps/unix/sysv/linux/sparc/sparc32/setegid.c new file mode 100644 index 0000000000..2e3a54c893 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/setegid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/setegid.c> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/seteuid.c b/sysdeps/unix/sysv/linux/sparc/sparc32/seteuid.c new file mode 100644 index 0000000000..18e41d08c1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/seteuid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/seteuid.c> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/setfsgid.c b/sysdeps/unix/sysv/linux/sparc/sparc32/setfsgid.c new file mode 100644 index 0000000000..0886712569 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/setfsgid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/setfsgid.c> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/setfsuid.c b/sysdeps/unix/sysv/linux/sparc/sparc32/setfsuid.c new file mode 100644 index 0000000000..a9f22eb8ab --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/setfsuid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/setfsuid.c> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/setgid.c b/sysdeps/unix/sysv/linux/sparc/sparc32/setgid.c new file mode 100644 index 0000000000..377021d9ec --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/setgid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/setgid.c> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/setresgid.c b/sysdeps/unix/sysv/linux/sparc/sparc32/setresgid.c new file mode 100644 index 0000000000..daca1a4833 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/setresgid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/setresgid.c> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/setresuid.c b/sysdeps/unix/sysv/linux/sparc/sparc32/setresuid.c new file mode 100644 index 0000000000..3aeabe9ad7 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/setresuid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/setresuid.c> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/setuid.c b/sysdeps/unix/sysv/linux/sparc/sparc32/setuid.c new file mode 100644 index 0000000000..de394379be --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/setuid.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/setuid.c> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list index 14c4691896..fce5b5fcf9 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list @@ -1,6 +1,10 @@ # File name Caller Syscall name # args Strong name Weak names s_getgroups getgroups getgroups 2 __syscall_getgroups +s_getpagesize getpagesize getpagesize 0 __syscall_getpagesize s_llseek llseek _llseek 5 __sys_llseek +s_setgid setgid setgid 1 __syscall_setgid s_setgroups setgroups setgroups 2 __syscall_setgroups -s_getpagesize getpagesize getpagesize 0 __syscall_getpagesize +s_setresgid setresgid setresgid 3 __syscall_setresgid +s_setresuid setresuid setresuid 3 __syscall_setresuid +s_setuid setuid setuid 1 __syscall_setuid |