Skip to content

Commit

Permalink
Remove sys/syscall.h, sys/types.h, linux/posix_types.h, sysdep.h and …
Browse files Browse the repository at this point in the history
…pthread-functions.h includes. Include setxid.h. Use INLINE_SETXID_SYSCALL macro instead of INLINE_SYSCALL, kill the HAVE_PTR__NPTL_SETXID guarded snippets.
  • Loading branch information
Ulrich Drepper committed Nov 12, 2004
1 parent 2931137 commit 85bd633
Showing 20 changed files with 59 additions and 453 deletions.
26 changes: 2 additions & 24 deletions sysdeps/unix/sysv/linux/alpha/setregid.c
Original file line number Diff line number Diff line change
@@ -18,35 +18,13 @@

#include <errno.h>
#include <unistd.h>
#include <sys/types.h>

#include <sysdep.h>
#include <sys/syscall.h>

#include <linux/posix_types.h>
#include "kernel-features.h"
#include <pthread-functions.h>
#include <setxid.h>


int
__setregid (gid_t rgid, gid_t egid)
{
int result;

result = INLINE_SYSCALL (setregid, 2, (signed int)rgid, (signed int)egid);

#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
{
struct xid_command cmd;
cmd.syscall_no = __NR_setregid;
cmd.id[0] = rgid;
cmd.id[1] = egid;
__libc_pthread_functions.ptr__nptl_setxid (&cmd);
}
#endif

return result;
return INLINE_SETXID_SYSCALL (setregid, 2, (int) rgid, (int) egid);
}
#ifndef __setregid
weak_alias (__setregid, setregid)
28 changes: 3 additions & 25 deletions sysdeps/unix/sysv/linux/alpha/setresgid.c
Original file line number Diff line number Diff line change
@@ -18,36 +18,14 @@

#include <errno.h>
#include <unistd.h>
#include <sys/types.h>

#include <sysdep.h>
#include <sys/syscall.h>

#include <linux/posix_types.h>
#include "kernel-features.h"
#include <pthread-functions.h>
#include <setxid.h>


int
__setresgid (gid_t rgid, gid_t egid, gid_t sgid)
{
int result;

result = INLINE_SYSCALL (setresgid, 3, (signed int)rgid, (signed int)egid, (signed int)sgid);

#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
{
struct xid_command cmd;
cmd.syscall_no = __NR_setresgid;
cmd.id[0] = rgid;
cmd.id[1] = egid;
cmd.id[2] = sgid;
__libc_pthread_functions.ptr__nptl_setxid (&cmd);
}
#endif

return result;
return INLINE_SETXID_SYSCALL (setresgid, 3, (int) rgid,
(int) egid, (int) sgid);
}
libc_hidden_def (__setresgid)
#ifndef __setresgid
28 changes: 3 additions & 25 deletions sysdeps/unix/sysv/linux/alpha/setresuid.c
Original file line number Diff line number Diff line change
@@ -18,36 +18,14 @@

#include <errno.h>
#include <unistd.h>
#include <sys/types.h>

#include <sysdep.h>
#include <sys/syscall.h>

#include <linux/posix_types.h>
#include "kernel-features.h"
#include <pthread-functions.h>
#include <setxid.h>


int
__setresuid (uid_t ruid, uid_t euid, uid_t suid)
{
int result;

result = INLINE_SYSCALL (setresuid, 3, (signed int)ruid, (signed int)euid, (signed int)suid);

#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
{
struct xid_command cmd;
cmd.syscall_no = __NR_setresuid;
cmd.id[0] = ruid;
cmd.id[1] = euid;
cmd.id[2] = suid;
__libc_pthread_functions.ptr__nptl_setxid (&cmd);
}
#endif

return result;
return INLINE_SETXID_SYSCALL (setresuid, 3, (int) ruid,
(int) euid, (int) suid);
}
libc_hidden_def (__setresuid)
#ifndef __setresuid
26 changes: 2 additions & 24 deletions sysdeps/unix/sysv/linux/alpha/setreuid.c
Original file line number Diff line number Diff line change
@@ -18,35 +18,13 @@

#include <errno.h>
#include <unistd.h>
#include <sys/types.h>

#include <sysdep.h>
#include <sys/syscall.h>

#include <linux/posix_types.h>
#include "kernel-features.h"
#include <pthread-functions.h>
#include <setxid.h>


int
__setreuid (uid_t ruid, uid_t euid)
{
int result;

result = INLINE_SYSCALL (setreuid, 2, (signed int)ruid, (signed int)euid);

#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
{
struct xid_command cmd;
cmd.syscall_no = __NR_setreuid;
cmd.id[0] = ruid;
cmd.id[1] = euid;
__libc_pthread_functions.ptr__nptl_setxid (&cmd);
}
#endif

return result;
return INLINE_SETXID_SYSCALL (setreuid, 2, (int) ruid, (int) euid);
}
#ifndef __setreuid
weak_alias (__setreuid, setreuid)
19 changes: 2 additions & 17 deletions sysdeps/unix/sysv/linux/i386/setegid.c
Original file line number Diff line number Diff line change
@@ -18,11 +18,8 @@

#include <errno.h>
#include <unistd.h>
#include <sys/types.h>

#include <sysdep.h>
#include <setxid.h>
#include "kernel-features.h"
#include <pthread-functions.h>


#ifdef __NR_setresgid
@@ -42,7 +39,7 @@ setegid (gid)
}

#if __ASSUME_32BITUIDS > 0
result = INLINE_SYSCALL (setresgid32, 3, -1, gid, -1);
result = INLINE_SETXID_SYSCALL (setresgid32, 3, -1, gid, -1);
#else
/* First try the syscall. */
# ifdef __NR_setresgid
@@ -59,18 +56,6 @@ setegid (gid)
result = __setregid (-1, gid);
#endif

#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
{
struct xid_command cmd;
cmd.syscall_no = __NR_setresgid32;
cmd.id[0] = -1;
cmd.id[1] = gid;
cmd.id[2] = -1;
__libc_pthread_functions.ptr__nptl_setxid (&cmd);
}
#endif

return result;
}
libc_hidden_def (setegid)
19 changes: 2 additions & 17 deletions sysdeps/unix/sysv/linux/i386/seteuid.c
Original file line number Diff line number Diff line change
@@ -17,12 +17,9 @@
02111-1307 USA. */

#include <errno.h>
#include <sys/types.h>
#include <unistd.h>

#include <sysdep.h>
#include <setxid.h>
#include "kernel-features.h"
#include <pthread-functions.h>


#ifdef __NR_setresuid
@@ -41,7 +38,7 @@ seteuid (uid_t uid)
}

#if __ASSUME_32BITUIDS > 0
result = INLINE_SYSCALL (setresuid32, 3, -1, uid, -1);
result = INLINE_SETXID_SYSCALL (setresuid32, 3, -1, uid, -1);
#else
/* First try the syscall. */
# ifdef __NR_setresuid
@@ -58,18 +55,6 @@ seteuid (uid_t uid)
result = __setreuid (-1, uid);
#endif

#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
{
struct xid_command cmd;
cmd.syscall_no = __NR_setresuid32;
cmd.id[0] = -1;
cmd.id[1] = uid;
cmd.id[2] = -1;
__libc_pthread_functions.ptr__nptl_setxid (&cmd);
}
#endif

return result;
}
libc_hidden_def (seteuid)
28 changes: 5 additions & 23 deletions sysdeps/unix/sysv/linux/i386/setgid.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* Copyright (C) 1998, 2000, 2003, 2004
Free Software Foundation, Inc.
/* Copyright (C) 1998, 2000, 2003, 2004 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
@@ -19,15 +18,8 @@

#include <errno.h>
#include <unistd.h>
#include <sys/types.h>

#include <sysdep.h>
#include <sys/syscall.h>

#include <linux/posix_types.h>

#include <setxid.h>
#include "kernel-features.h"
#include <pthread-functions.h>


#ifdef __NR_setgid32
@@ -44,14 +36,14 @@ __setgid (gid_t gid)
int result;

#if __ASSUME_32BITUIDS > 0
result = INLINE_SYSCALL (setgid32, 1, gid);
result = INLINE_SETXID_SYSCALL (setgid32, 1, gid);
#else
# ifdef __NR_setgid32
if (__libc_missing_32bit_uids <= 0)
{
int saved_errno = errno;

result = INLINE_SYSCALL (setgid32, 1, gid);
result = INLINE_SETXID_SYSCALL (setgid32, 1, gid);

if (result == 0)
goto out;
@@ -70,22 +62,12 @@ __setgid (gid_t gid)
return -1;
}

result = INLINE_SYSCALL (setgid, 1, gid);
result = INLINE_SETXID_SYSCALL (setgid, 1, gid);
# ifdef __NR_setgid32
out:
# endif
#endif

#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
{
struct xid_command cmd;
cmd.syscall_no = __NR_setgid32;
cmd.id[0] = gid;
__libc_pthread_functions.ptr__nptl_setxid (&cmd);
}
#endif

return result;
}
#ifndef __setgid
25 changes: 4 additions & 21 deletions sysdeps/unix/sysv/linux/i386/setregid.c
Original file line number Diff line number Diff line change
@@ -17,15 +17,9 @@
02111-1307 USA. */

#include <errno.h>
#include <sys/types.h>
#include <unistd.h>

#include <sysdep.h>
#include <sys/syscall.h>

#include <linux/posix_types.h>
#include <setxid.h>
#include "kernel-features.h"
#include <pthread-functions.h>


#ifdef __NR_setregid32
@@ -42,14 +36,14 @@ __setregid (gid_t rgid, gid_t egid)
int result;

#if __ASSUME_32BITUIDS > 0
result = INLINE_SYSCALL (setregid32, 2, rgid, egid);
result = INLINE_SETXID_SYSCALL (setregid32, 2, rgid, egid);
#else
# ifdef __NR_setregid32
if (__libc_missing_32bit_uids <= 0)
{
int saved_errno = errno;

result = INLINE_SYSCALL (setregid32, 2, rgid, egid);
result = INLINE_SETXID_SYSCALL (setregid32, 2, rgid, egid);

if (result == 0)
goto out;
@@ -67,23 +61,12 @@ __setregid (gid_t rgid, gid_t egid)
return -1;
}

result = INLINE_SYSCALL (setregid, 2, rgid, egid);
result = INLINE_SETXID_SYSCALL (setregid, 2, rgid, egid);
# ifdef __NR_setregid32
out:
# endif
#endif

#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
{
struct xid_command cmd;
cmd.syscall_no = __NR_setregid32;
cmd.id[0] = rgid;
cmd.id[1] = egid;
__libc_pthread_functions.ptr__nptl_setxid (&cmd);
}
#endif

return result;
}
#ifndef __setregid
Loading

0 comments on commit 85bd633

Please sign in to comment.