summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/local-setxid.h4
-rw-r--r--sysdeps/i386/Makefile8
-rw-r--r--sysdeps/posix/spawni.c15
-rw-r--r--sysdeps/unix/sysv/linux/local-setxid.h23
4 files changed, 44 insertions, 6 deletions
diff --git a/sysdeps/generic/local-setxid.h b/sysdeps/generic/local-setxid.h
new file mode 100644
index 0000000000..b70d9ffb32
--- /dev/null
+++ b/sysdeps/generic/local-setxid.h
@@ -0,0 +1,4 @@
+/* No special support. Fall back to the regular functions. */
+
+#define local_seteuid(id) seteuid (id)
+#define local_setegid(id) setegid (id)
diff --git a/sysdeps/i386/Makefile b/sysdeps/i386/Makefile
index ddd3d04e07..e192b91dbd 100644
--- a/sysdeps/i386/Makefile
+++ b/sysdeps/i386/Makefile
@@ -64,4 +64,12 @@ endif
ifneq (,$(filter -mno-tls-direct-seg-refs,$(CFLAGS)))
defines += -DNO_TLS_DIRECT_SEG_REFS
+else
+# .a libraries are not performance critical and so we
+# build them without direct TLS segment references
+# always.
+CPPFLAGS-.o += -DNO_TLS_DIRECT_SEG_REFS
+CFLAGS-.o += -mno-tls-direct-seg-refs
+CPPFLAGS-.oS += -DNO_TLS_DIRECT_SEG_REFS
+CFLAGS-.oS += -mno-tls-direct-seg-refs
endif
diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c
index 27699f4df8..29803a8461 100644
--- a/sysdeps/posix/spawni.c
+++ b/sysdeps/posix/spawni.c
@@ -1,5 +1,5 @@
/* Guts of POSIX spawn interface. Generic POSIX.1 version.
- Copyright (C) 2000,2001,2002,2003,2004,2005 Free Software Foundation, Inc.
+ Copyright (C) 2000-2005, 2006 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
@@ -26,6 +26,7 @@
#include <unistd.h>
#include "spawn_int.h"
#include <not-cancel.h>
+#include <local-setxid.h>
/* The Unix standard contains a long explanation of the way to signal
@@ -155,7 +156,8 @@ __spawni (pid_t *pid, const char *file,
/* Set the effective user and group IDs. */
if ((flags & POSIX_SPAWN_RESETIDS) != 0
- && (seteuid (__getuid ()) != 0 || setegid (__getgid ()) != 0))
+ && (local_seteuid (__getuid ()) != 0
+ || local_setegid (__getgid ()) != 0))
_exit (SPAWN_ERROR);
/* Execute the file actions. */
@@ -177,9 +179,10 @@ __spawni (pid_t *pid, const char *file,
case spawn_do_open:
{
- int new_fd = __open64 (action->action.open_action.path,
- action->action.open_action.oflag,
- action->action.open_action.mode);
+ int new_fd = open_not_cancel (action->action.open_action.path,
+ action->action.open_action.oflag
+ | O_LARGEFILE,
+ action->action.open_action.mode);
if (new_fd == -1)
/* The `open' call failed. */
@@ -193,7 +196,7 @@ __spawni (pid_t *pid, const char *file,
/* The `dup2' call failed. */
_exit (SPAWN_ERROR);
- if (__close (new_fd) != 0)
+ if (close_not_cancel (new_fd) != 0)
/* The `close' call failed. */
_exit (SPAWN_ERROR);
}
diff --git a/sysdeps/unix/sysv/linux/local-setxid.h b/sysdeps/unix/sysv/linux/local-setxid.h
new file mode 100644
index 0000000000..0579687982
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/local-setxid.h
@@ -0,0 +1,23 @@
+/* SETxID functions which only have to change the local thread and
+ none of the possible other threads. */
+#include <kernel-features.h>
+#include <sysdep.h>
+
+/* If we can use the syscall directly, use it. */
+#if __ASSUME_32BITUIDS > 0 && defined __NR_setresuid32
+# define local_seteuid(id) INLINE_SYSCALL (setresuid32, 3, -1, id, -1)
+#elif __ASSUME_SETRESUID_SYSCALL > 0
+# define local_seteuid(id) INLINE_SYSCALL (setresuid, 3, -1, id, -1)
+#else
+# define local_seteuid(id) seteuid (id)
+#endif
+
+
+/* If we can use the syscall directly, use it. */
+#if __ASSUME_32BITUIDS > 0 && defined __NR_setresgid32
+# define local_setegid(id) INLINE_SYSCALL (setresgid32, 3, -1, id, -1)
+#elif __ASSUME_SETRESGID_SYSCALL > 0
+# define local_setegid(id) INLINE_SYSCALL (setresgid, 3, -1, id, -1)
+#else
+# define local_setegid(id) setegid (id)
+#endif