From 313fed01112e9d6a9560ac07ab4b1a79d3209d45 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 17 Jan 2000 05:24:52 +0000 Subject: Update. 2000-01-12 Andreas Jaeger * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_32BITUIDS): Added for Linux 2.3.39+. * sysdeps/unix/sysv/linux/getresgid.c: Support 32bit UIDs and 32bit GIDs. * sysdeps/unix/sysv/linux/getresuid.c: Likewise. * sysdeps/unix/sysv/linux/i386/chown.c: Likewise. * sysdeps/unix/sysv/linux/i386/getgroups.c: Likewise. * sysdeps/unix/sysv/linux/i386/setegid.c: Likewise. * sysdeps/unix/sysv/linux/i386/seteuid.c: Likewise. * sysdeps/unix/sysv/linux/i386/setfsgid.c: Likewise. * sysdeps/unix/sysv/linux/i386/setfsuid.c: Likewise. * sysdeps/unix/sysv/linux/i386/setgid.c: Likewise. * sysdeps/unix/sysv/linux/i386/setgroups.c: Likewise. * sysdeps/unix/sysv/linux/i386/setregid.c: Likewise. * sysdeps/unix/sysv/linux/i386/setresgid.c: Likewise. * sysdeps/unix/sysv/linux/i386/setresuid.c: Likewise. * sysdeps/unix/sysv/linux/i386/setreuid.c: Likewise. * sysdeps/unix/sysv/linux/i386/setuid.c: Likewise. * sysdeps/unix/sysv/linux/setegid.c: Likewise. * sysdeps/unix/sysv/linux/arm/chown.c: New file. * sysdeps/unix/sysv/linux/arm/fchown.c: New file. * sysdeps/unix/sysv/linux/arm/geteuid.c: New file. * sysdeps/unix/sysv/linux/arm/getegid.c: New file. * sysdeps/unix/sysv/linux/arm/getuid.c: New file. * sysdeps/unix/sysv/linux/arm/getgid.c: New file. * sysdeps/unix/sysv/linux/arm/lchown.c: New file. * sysdeps/unix/sysv/linux/i386/fchown.c: New file. * sysdeps/unix/sysv/linux/i386/getegid.c: New file. * sysdeps/unix/sysv/linux/i386/geteuid.c: New file. * sysdeps/unix/sysv/linux/i386/getgid.c: New file. * sysdeps/unix/sysv/linux/i386/getuid.c: New file. * sysdeps/unix/sysv/linux/i386/lchown.c: New file. * sysdeps/unix/sysv/linux/m68k/chown.c: New file. * sysdeps/unix/sysv/linux/m68k/fchown.c: New file. * sysdeps/unix/sysv/linux/m68k/getegid.c: New file. * sysdeps/unix/sysv/linux/m68k/geteuid.c: New file. * sysdeps/unix/sysv/linux/m68k/getgid.c: New file. * sysdeps/unix/sysv/linux/m68k/getuid.c: New file. * sysdeps/unix/sysv/linux/m68k/lchown.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/chown.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/fchown.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/getegid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/geteuid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/getgid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/getuid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/lchown.c: New file. Based on a patch by Chris Wing . 2000-01-14 Jakub Jelinek * sysdeps/unix/sysv/linux/sparc/sys/procfs.h: New file. 2000-01-13 Jakub Jelinek * sysdeps/generic/backtrace.c: Include signal.h which sigcontextinfo.h headers are used to expect. * sysdeps/unix/sysv/linux/sparc/sparc32/register-dump.h (register_dump): Fix a typo in the printout. Avoid using reg_window, so that asm/ptrace.h is not necessary. * sysdeps/unix/sysv/linux/sparc/sparc32/sigcontextinfo.h (ADVANCE_STACK_FRAME): Likewise. * stdlib/longlong.h: Avoid using __sparc_v9__ ifdefs. * sysdeps/sparc/sparc32/bits/wordsize.h: Likewise. * sysdeps/sparc/sparc64/bits/wordsize.h: Likewise. * sysdeps/unix/sysv/linux/sparc/bits/fcntl.h: Include bits/wordsize.h to make it clear this file depends on __WORDSIZE. * sysdeps/unix/sysv/linux/ftruncate64.c (__have_no_truncate64): Renamed from have_no_truncate64. * sysdeps/unix/sysv/linux/truncate64.c (__have_no_truncate64): Likewise. --- sysdeps/unix/sysv/linux/i386/chown.c | 46 ++++++++++++++++++- sysdeps/unix/sysv/linux/i386/fchown.c | 73 +++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/i386/getegid.c | 62 +++++++++++++++++++++++++ sysdeps/unix/sysv/linux/i386/geteuid.c | 62 +++++++++++++++++++++++++ sysdeps/unix/sysv/linux/i386/getgid.c | 63 +++++++++++++++++++++++++ sysdeps/unix/sysv/linux/i386/getgroups.c | 38 ++++++++++++--- sysdeps/unix/sysv/linux/i386/getuid.c | 63 +++++++++++++++++++++++++ sysdeps/unix/sysv/linux/i386/lchown.c | 79 ++++++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/i386/setegid.c | 12 +---- sysdeps/unix/sysv/linux/i386/seteuid.c | 11 +---- sysdeps/unix/sysv/linux/i386/setfsgid.c | 33 ++++++++++++- sysdeps/unix/sysv/linux/i386/setfsuid.c | 32 ++++++++++++- sysdeps/unix/sysv/linux/i386/setgid.c | 33 ++++++++++++- sysdeps/unix/sysv/linux/i386/setgroups.c | 37 ++++++++++++--- sysdeps/unix/sysv/linux/i386/setregid.c | 32 ++++++++++++- sysdeps/unix/sysv/linux/i386/setresgid.c | 33 ++++++++++++- sysdeps/unix/sysv/linux/i386/setresuid.c | 33 ++++++++++++- sysdeps/unix/sysv/linux/i386/setreuid.c | 32 ++++++++++++- sysdeps/unix/sysv/linux/i386/setuid.c | 31 ++++++++++++- 19 files changed, 762 insertions(+), 43 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/i386/fchown.c create mode 100644 sysdeps/unix/sysv/linux/i386/getegid.c create mode 100644 sysdeps/unix/sysv/linux/i386/geteuid.c create mode 100644 sysdeps/unix/sysv/linux/i386/getgid.c create mode 100644 sysdeps/unix/sysv/linux/i386/getuid.c create mode 100644 sysdeps/unix/sysv/linux/i386/lchown.c (limited to 'sysdeps/unix/sysv/linux/i386') diff --git a/sysdeps/unix/sysv/linux/i386/chown.c b/sysdeps/unix/sysv/linux/i386/chown.c index 9ab03e3a7c..9addfd0598 100644 --- a/sysdeps/unix/sysv/linux/i386/chown.c +++ b/sysdeps/unix/sysv/linux/i386/chown.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2000 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 @@ -23,6 +23,9 @@ #include #include +#include + + /* In Linux 2.1.x the chown functions have been changed. A new function lchown @@ -39,6 +42,15 @@ extern int __syscall_chown (const char *__file, #if defined __NR_lchown || __ASSUME_LCHOWN_SYSCALL > 0 /* Running under Linux > 2.1.80. */ +# ifdef __NR_chown32 +extern int __syscall_chown32 (const char *__file, + __kernel_uid32_t owner, __kernel_gid32_t group); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +# endif /* __NR_chown32 */ int __real_chown (const char *file, uid_t owner, gid_t group) @@ -50,6 +62,20 @@ __real_chown (const char *file, uid_t owner, gid_t group) if (!__libc_old_chown) { int saved_errno = errno; +# ifdef __NR_chown32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (chown32, 3, file, owner, group); + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_chown32 */ result = INLINE_SYSCALL (chown, 3, file, owner, group); if (result >= 0 || errno != ENOSYS) @@ -60,7 +86,25 @@ __real_chown (const char *file, uid_t owner, gid_t group) } return __lchown (file, owner, group); +# elif __ASSUME_32BITUIDS + /* This implies __ASSUME_LCHOWN_SYSCALL. */ + return INLINE_SYSCALL (chown32, 3, file, owner, group); # else + /* !__ASSUME_32BITUIDS && ASSUME_LCHOWN_SYSCALL */ +# ifdef __NR_chown32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (chown32, 3, file, owner, group); + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_chown32 */ return INLINE_SYSCALL (chown, 3, file, owner, group); # endif } diff --git a/sysdeps/unix/sysv/linux/i386/fchown.c b/sysdeps/unix/sysv/linux/i386/fchown.c new file mode 100644 index 0000000000..7d4c360dbd --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/fchown.c @@ -0,0 +1,73 @@ +/* Copyright (C) 2000 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 +#include + +#include +#include + +#include +#include "kernel-features.h" + +extern int __syscall_fchown (int __fd, + __kernel_uid_t __owner, __kernel_gid_t __group); + +#ifdef __NR_fchown32 +extern int __syscall_fchown32 (int __fd, + __kernel_uid32_t __owner, __kernel_gid32_t __group); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +#endif /* __NR_fchown32 */ + +int +__fchown (int fd, uid_t owner, gid_t group) +{ +#if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (fchown32, 3, fd, owner, group); +#else +# ifdef __NR_fchown32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (fchown32, 3, fd, owner, group); + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_fchown32 */ + + if ( (owner != (uid_t) ((__kernel_uid_t) owner)) || + (group != (gid_t) ((__kernel_gid_t) group)) ) + { + __set_errno (EINVAL); + return -1; + } + + return INLINE_SYSCALL (fchown, 3, fd, owner, group); +#endif +} + +weak_alias (__fchown, fchown) diff --git a/sysdeps/unix/sysv/linux/i386/getegid.c b/sysdeps/unix/sysv/linux/i386/getegid.c new file mode 100644 index 0000000000..05dd15d986 --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/getegid.c @@ -0,0 +1,62 @@ +/* Copyright (C) 2000 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 +#include + +#include +#include +#include "kernel-features.h" + +extern int __syscall_getegid (void); + +#ifdef __NR_getegid32 +extern int __syscall_getegid32 (void); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +#endif /* __NR_getegid32 */ + +gid_t +__getegid (void) +{ +#if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (getegid32, 0); +#else +# ifdef __NR_getegid32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (getegid32, 0); + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_getegid32 */ + + return INLINE_SYSCALL (getegid, 0); +#endif +} + +weak_alias (__getegid, getegid) diff --git a/sysdeps/unix/sysv/linux/i386/geteuid.c b/sysdeps/unix/sysv/linux/i386/geteuid.c new file mode 100644 index 0000000000..e2f932a975 --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/geteuid.c @@ -0,0 +1,62 @@ +/* Copyright (C) 2000 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 +#include + +#include +#include +#include "kernel-features.h" + +extern int __syscall_geteuid (void); + +#ifdef __NR_geteuid32 +extern int __syscall_geteuid32 (void); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +#endif /* __NR_geteuid32 */ + +uid_t +__geteuid (void) +{ +#if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (geteuid32, 0); +#else +# ifdef __NR_geteuid32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (geteuid32, 0); + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_geteuid32 */ + + return INLINE_SYSCALL (geteuid, 0); +#endif +} + +weak_alias (__geteuid, geteuid) diff --git a/sysdeps/unix/sysv/linux/i386/getgid.c b/sysdeps/unix/sysv/linux/i386/getgid.c new file mode 100644 index 0000000000..19794aac36 --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/getgid.c @@ -0,0 +1,63 @@ +/* Copyright (C) 2000 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 +#include + +#include +#include + +#include "kernel-features.h" + +extern int __syscall_getgid (void); + +#ifdef __NR_getgid32 +extern int __syscall_getgid32 (void); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +#endif /* __NR_getgid32 */ + +gid_t +__getgid (void) +{ +#if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (getgid32, 0); +#else +# ifdef __NR_getgid32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (getgid32, 0); + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_getgid32 */ + + return INLINE_SYSCALL (getgid, 0); +#endif +} + +weak_alias (__getgid, getgid) diff --git a/sysdeps/unix/sysv/linux/i386/getgroups.c b/sysdeps/unix/sysv/linux/i386/getgroups.c index 5484f72f1c..b538f8f79a 100644 --- a/sysdeps/unix/sysv/linux/i386/getgroups.c +++ b/sysdeps/unix/sysv/linux/i386/getgroups.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 2000 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 @@ -23,17 +23,25 @@ #include #include - #include +#include + + +extern int __syscall_getgroups(int, __kernel_gid_t *); -extern int __syscall_getgroups __P ((int, __kernel_gid_t *)); +#ifdef __NR_getgroups32 +extern int __syscall_getgroups32 (int, __kernel_gid32_t *); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +#endif /* __NR_getgroups32 */ /* For Linux we must convert the array of groups from the format that the kernel returns. */ int -__getgroups (n, groups) - int n; - gid_t *groups; +__getgroups (int n, gid_t *groups) { if (n < 0) { @@ -42,8 +50,25 @@ __getgroups (n, groups) } else { +#if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (getgroups32, 2, n, groups); +#else int i, ngids; __kernel_gid_t kernel_groups[n = MIN (n, __sysconf (_SC_NGROUPS_MAX))]; +# ifdef __NR_getgroups32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (getgroups32, 2, n, groups); + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_getgroups32 */ ngids = INLINE_SYSCALL (getgroups, 2, n, kernel_groups); if (n != 0 && ngids > 0) @@ -52,6 +77,7 @@ __getgroups (n, groups) return ngids; } +#endif } weak_alias (__getgroups, getgroups) diff --git a/sysdeps/unix/sysv/linux/i386/getuid.c b/sysdeps/unix/sysv/linux/i386/getuid.c new file mode 100644 index 0000000000..d160e4423a --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/getuid.c @@ -0,0 +1,63 @@ +/* Copyright (C) 2000 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 +#include + +#include +#include + +#include "kernel-features.h" + +extern int __syscall_getuid (void); + +#ifdef __NR_getuid32 +extern int __syscall_getuid32 (void); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. This is the definition */ +int __libc_missing_32bit_uids; +# endif +#endif /* __NR_getuid32 */ + +uid_t +__getuid (void) +{ +#if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (getuid32, 0); +#else +# ifdef __NR_getuid32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (getuid32, 0); + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_getuid32 */ + + return INLINE_SYSCALL (getuid, 0); +#endif +} + +weak_alias (__getuid, getuid) diff --git a/sysdeps/unix/sysv/linux/i386/lchown.c b/sysdeps/unix/sysv/linux/i386/lchown.c new file mode 100644 index 0000000000..86ff7d518d --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/lchown.c @@ -0,0 +1,79 @@ +/* Copyright (C) 2000 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 +#include + +#include +#include + +#include +#include "kernel-features.h" + +#ifdef __NR_lchown +extern int __syscall_lchown (const char *__file, + __kernel_uid_t __owner, __kernel_gid_t __group); + +# ifdef __NR_lchown32 +extern int __syscall_lchown32 (const char *__file, + __kernel_uid32_t __owner, __kernel_gid32_t __group); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +# endif /* __NR_lchown32 */ + +int +__lchown (const char *file, uid_t owner, gid_t group) +{ +# if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (lchown32, 3, file, owner, group); +# else +# ifdef __NR_lchown32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (lchown32, 3, file, owner, group); + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_lchown32 */ + + if ( (owner != (uid_t) ((__kernel_uid_t) owner)) || + (group != (gid_t) ((__kernel_gid_t) group)) ) + { + __set_errno (EINVAL); + return -1; + } + + return INLINE_SYSCALL (lchown, 3, file, owner, group); +# endif +} + +weak_alias (__lchown, lchown) + +#else +# include +#endif + diff --git a/sysdeps/unix/sysv/linux/i386/setegid.c b/sysdeps/unix/sysv/linux/i386/setegid.c index e29d2eab7b..d4883fe31a 100644 --- a/sysdeps/unix/sysv/linux/i386/setegid.c +++ b/sysdeps/unix/sysv/linux/i386/setegid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1995, 96, 97, 98, 2000 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,22 +16,12 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include #include #include -#include - 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 index e82ecc36e9..c2b03f91e3 100644 --- a/sysdeps/unix/sysv/linux/i386/seteuid.c +++ b/sysdeps/unix/sysv/linux/i386/seteuid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000 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 @@ -21,7 +21,6 @@ #include #include -#include #ifdef __NR_setresuid extern int __setresuid (uid_t ruid, uid_t euid, uid_t suid); @@ -31,14 +30,6 @@ 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); diff --git a/sysdeps/unix/sysv/linux/i386/setfsgid.c b/sysdeps/unix/sysv/linux/i386/setfsgid.c index 434b19377b..6fd7e46489 100644 --- a/sysdeps/unix/sysv/linux/i386/setfsgid.c +++ b/sysdeps/unix/sysv/linux/i386/setfsgid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000 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 @@ -22,15 +22,43 @@ #include #include - #include +#include "kernel-features.h" + #ifdef __NR_setfsgid + extern int __syscall_setfsgid (__kernel_gid_t); +# ifdef __NR_setfsgid32 +extern int __syscall_setfsgid32 (__kernel_gid32_t); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +# endif /* __NR_setfsgid32 */ + int setfsgid (gid_t gid) { +# if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (setfsgid32, 1, gid); +# else +# ifdef __NR_setfsgid32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (setfsgid32, 1, gid); + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_setfsgid32 */ if (gid != (gid_t) ((__kernel_gid_t) gid)) { __set_errno (EINVAL); @@ -38,5 +66,6 @@ setfsgid (gid_t gid) } return INLINE_SYSCALL (setfsgid, 1, gid); +# endif } #endif diff --git a/sysdeps/unix/sysv/linux/i386/setfsuid.c b/sysdeps/unix/sysv/linux/i386/setfsuid.c index f3771694a1..cf7bc16476 100644 --- a/sysdeps/unix/sysv/linux/i386/setfsuid.c +++ b/sysdeps/unix/sysv/linux/i386/setfsuid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000 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 @@ -24,13 +24,42 @@ #include #include +#include "kernel-features.h" #ifdef __NR_setfsuid + extern int __syscall_setfsuid (__kernel_uid_t); +# ifdef __NR_setfsuid32 +extern int __syscall_setfsuid32 (__kernel_uid32_t); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +# endif /* __NR_setfsuid32 */ + int setfsuid (uid_t uid) { +# if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (setfsuid32, 1, uid); +# else +# ifdef __NR_setfsuid32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (setfsuid32, 1, uid); + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_setfsuid32 */ + if (uid != (uid_t) ((__kernel_uid_t) uid)) { __set_errno (EINVAL); @@ -38,5 +67,6 @@ setfsuid (uid_t uid) } return INLINE_SYSCALL (setfsuid, 1, uid); +# endif } #endif diff --git a/sysdeps/unix/sysv/linux/i386/setgid.c b/sysdeps/unix/sysv/linux/i386/setgid.c index 2ab8dfda34..2a81302527 100644 --- a/sysdeps/unix/sysv/linux/i386/setgid.c +++ b/sysdeps/unix/sysv/linux/i386/setgid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000 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 @@ -25,11 +25,41 @@ #include +#include "kernel-features.h" + extern int __syscall_setgid (__kernel_gid_t); +#ifdef __NR_setgid32 +extern int __syscall_setgid32 (__kernel_gid32_t); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +#endif /* __NR_setgid32 */ + int __setgid (gid_t gid) { +#if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (setgid32, 1, gid); +#else +# ifdef __NR_setgid32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (setgid32, 1, gid); + + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_setgid32 */ + if (gid == (gid_t) ~0 || gid != (gid_t) ((__kernel_gid_t) gid)) { @@ -38,5 +68,6 @@ __setgid (gid_t gid) } return INLINE_SYSCALL (setgid, 1, gid); +#endif } weak_alias (__setgid, setgid) diff --git a/sysdeps/unix/sysv/linux/i386/setgroups.c b/sysdeps/unix/sysv/linux/i386/setgroups.c index e57004f8ac..7c750acc74 100644 --- a/sysdeps/unix/sysv/linux/i386/setgroups.c +++ b/sysdeps/unix/sysv/linux/i386/setgroups.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 2000 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 @@ -23,18 +23,26 @@ #include #include - #include +#include "kernel-features.h" + + +extern int __syscall_setgroups (int, const __kernel_gid_t *); -extern int __syscall_setgroups __P ((int, const __kernel_gid_t *)); +#ifdef __NR_setgroups32 +extern int __syscall_setgroups32 __P ((int, const __kernel_gid32_t *)); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +#endif /* __NR_setgroups32 */ /* Set the group set for the current user to GROUPS (N of them). For Linux we must convert the array of groups into the format that the kernel expects. */ int -setgroups (n, groups) - size_t n; - const gid_t *groups; +setgroups (size_t n, const gid_t *groups) { if (n > (size_t) __sysconf (_SC_NGROUPS_MAX)) { @@ -43,9 +51,25 @@ setgroups (n, groups) } else { +#if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (setgroups32, 2, n, groups); +#else size_t i; __kernel_gid_t kernel_groups[n]; +# ifdef __NR_setgroups32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (setgroups32, 2, n, groups); + if (result == 0 || errno != ENOSYS) + return result; + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_setgroups32 */ for (i = 0; i < n; i++) { kernel_groups[i] = groups[i]; @@ -58,4 +82,5 @@ setgroups (n, groups) return INLINE_SYSCALL (setgroups, 2, n, kernel_groups); } +#endif } diff --git a/sysdeps/unix/sysv/linux/i386/setregid.c b/sysdeps/unix/sysv/linux/i386/setregid.c index 98603bd2a2..4f00d30bc6 100644 --- a/sysdeps/unix/sysv/linux/i386/setregid.c +++ b/sysdeps/unix/sysv/linux/i386/setregid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000 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 @@ -24,12 +24,41 @@ #include #include +#include "kernel-features.h" + extern int __syscall_setregid (__kernel_gid_t, __kernel_gid_t); +#ifdef __NR_setregid32 +extern int __syscall_setregid32 (__kernel_gid32_t, __kernel_gid32_t); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +#endif /* __NR_setregid32 */ + int __setregid (gid_t rgid, gid_t egid) { +#if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (setregid32, 2, rgid, egid); +#else +# ifdef __NR_setregid32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (setregid32, 2, rgid, egid); + + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_setregid32 */ if ((rgid != (gid_t) -1 && rgid != (gid_t) (__kernel_gid_t) rgid) || (egid != (gid_t) -1 && egid != (gid_t) (__kernel_gid_t) egid)) { @@ -38,5 +67,6 @@ __setregid (gid_t rgid, gid_t egid) } return INLINE_SYSCALL (setregid, 2, rgid, egid); +#endif } weak_alias (__setregid, setregid) diff --git a/sysdeps/unix/sysv/linux/i386/setresgid.c b/sysdeps/unix/sysv/linux/i386/setresgid.c index ab2738582b..45dbcc8485 100644 --- a/sysdeps/unix/sysv/linux/i386/setresgid.c +++ b/sysdeps/unix/sysv/linux/i386/setresgid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000 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 @@ -24,14 +24,44 @@ #include #include +#include "kernel-features.h" + #ifdef __NR_setresgid extern int __syscall_setresgid (__kernel_gid_t rgid, __kernel_gid_t egid, __kernel_gid_t sgid); +# ifdef __NR_setresgid32 +extern int __syscall_setresgid32 (__kernel_gid32_t rgid, __kernel_gid32_t egid, + __kernel_gid32_t sgid); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +# endif /* __NR_setresgid32 */ + int setresgid (gid_t rgid, gid_t egid, gid_t sgid) { +# if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (setresgid32, 3, rgid, egid, sgid); +# else +# ifdef __NR_setresgid32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (setresgid32, 3, rgid, egid, sgid); + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_setresgid32 */ + if ((rgid != (gid_t) -1 && rgid != (gid_t) (__kernel_gid_t) rgid) || (egid != (gid_t) -1 && egid != (gid_t) (__kernel_gid_t) egid) || (sgid != (gid_t) -1 && sgid != (gid_t) (__kernel_gid_t) sgid)) @@ -41,5 +71,6 @@ setresgid (gid_t rgid, gid_t egid, gid_t sgid) } return INLINE_SYSCALL (setresgid, 3, rgid, egid, sgid); +# endif } #endif diff --git a/sysdeps/unix/sysv/linux/i386/setresuid.c b/sysdeps/unix/sysv/linux/i386/setresuid.c index 953b8294d6..90214526ab 100644 --- a/sysdeps/unix/sysv/linux/i386/setresuid.c +++ b/sysdeps/unix/sysv/linux/i386/setresuid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000 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 @@ -24,14 +24,44 @@ #include #include +#include "kernel-features.h" + #ifdef __NR_setresuid extern int __syscall_setresuid (__kernel_uid_t rgid, __kernel_uid_t egid, __kernel_uid_t sgid); +# ifdef __NR_setresuid32 +extern int __syscall_setresuid32 (__kernel_uid32_t rgid, __kernel_uid32_t egid, + __kernel_uid32_t sgid); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +# endif /* __NR_setresuid32 */ + int __setresuid (uid_t ruid, uid_t euid, uid_t suid) { +# if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (setresuid32, 3, ruid, euid, suid); +# else +# ifdef __NR_setresuid32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (setresuid32, 3, ruid, euid, suid); + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_setresuid32 */ + if ((ruid != (uid_t) -1 && ruid != (uid_t) (__kernel_uid_t) ruid) || (euid != (uid_t) -1 && euid != (uid_t) (__kernel_uid_t) euid) || (suid != (uid_t) -1 && suid != (uid_t) (__kernel_uid_t) suid)) @@ -41,6 +71,7 @@ __setresuid (uid_t ruid, uid_t euid, uid_t suid) } return INLINE_SYSCALL (setresuid, 3, ruid, euid, suid); +# endif } weak_alias (__setresuid, setresuid) #endif diff --git a/sysdeps/unix/sysv/linux/i386/setreuid.c b/sysdeps/unix/sysv/linux/i386/setreuid.c index f38f136920..58ddff2b00 100644 --- a/sysdeps/unix/sysv/linux/i386/setreuid.c +++ b/sysdeps/unix/sysv/linux/i386/setreuid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000 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 @@ -24,12 +24,41 @@ #include #include +#include "kernel-features.h" + extern int __syscall_setreuid (__kernel_uid_t, __kernel_uid_t); +#ifdef __NR_setreuid32 +extern int __syscall_setreuid32 (__kernel_uid32_t, __kernel_uid32_t); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +#endif /* __NR_setreuid32 */ + int __setreuid (uid_t ruid, uid_t euid) { +#if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (setreuid32, 2, ruid, euid); +#else +# ifdef __NR_setreuid32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (setreuid32, 2, ruid, euid); + + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_setreuid32 */ if ((ruid != (uid_t) -1 && ruid != (uid_t) (__kernel_uid_t) ruid) || (euid != (uid_t) -1 && euid != (uid_t) (__kernel_uid_t) euid)) { @@ -38,5 +67,6 @@ __setreuid (uid_t ruid, uid_t euid) } return INLINE_SYSCALL (setreuid, 2, ruid, euid); +#endif } weak_alias (__setreuid, setreuid) diff --git a/sysdeps/unix/sysv/linux/i386/setuid.c b/sysdeps/unix/sysv/linux/i386/setuid.c index 5e5346ca42..ed0d8fa0bd 100644 --- a/sysdeps/unix/sysv/linux/i386/setuid.c +++ b/sysdeps/unix/sysv/linux/i386/setuid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000 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 @@ -24,12 +24,40 @@ #include #include +#include "kernel-features.h" extern int __syscall_setuid (__kernel_uid_t); +#ifdef __NR_setuid32 +extern int __syscall_setuid32 (__kernel_uid32_t); +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +#endif /* __NR_setuid32 */ + int __setuid (uid_t uid) { +#if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (setuid32, 1, uid); +#else +# ifdef __NR_setuid32 + if (!__libc_missing_32bit_uids) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (setuid32, 1, uid); + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_setuid32 */ + if (uid == (uid_t) ~0 || uid != (uid_t) ((__kernel_uid_t) uid)) { @@ -38,5 +66,6 @@ __setuid (uid_t uid) } return INLINE_SYSCALL (setuid, 1, uid); +#endif } weak_alias (__setuid, setuid) -- cgit 1.4.1