diff mbox series

[03/28] Remove local-setxid.h

Message ID 20201118195552.2687336-4-adhemerval.zanella@linaro.org
State New
Headers show
Series More Linux syscall refactor | expand

Commit Message

Adhemerval Zanella Nov. 18, 2020, 7:55 p.m. UTC
The required Linux specific implementation is moved to internal
posix_spawn implementation.

No semantic changes expected.
---
 sysdeps/generic/local-setxid.h         |  4 ----
 sysdeps/posix/spawni.c                 |  5 ++---
 sysdeps/unix/sysv/linux/local-setxid.h | 16 ----------------
 sysdeps/unix/sysv/linux/spawni.c       | 19 ++++++++++++++++++-
 4 files changed, 20 insertions(+), 24 deletions(-)
 delete mode 100644 sysdeps/generic/local-setxid.h
 delete mode 100644 sysdeps/unix/sysv/linux/local-setxid.h
diff mbox series

Patch

diff --git a/sysdeps/generic/local-setxid.h b/sysdeps/generic/local-setxid.h
deleted file mode 100644
index b70d9ffb32..0000000000
--- a/sysdeps/generic/local-setxid.h
+++ /dev/null
@@ -1,4 +0,0 @@ 
-/* 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/posix/spawni.c b/sysdeps/posix/spawni.c
index 943a598771..2dcbc1bf24 100644
--- a/sysdeps/posix/spawni.c
+++ b/sysdeps/posix/spawni.c
@@ -26,7 +26,6 @@ 
 #include <sys/param.h>
 #include <sys/mman.h>
 #include <not-cancel.h>
-#include <local-setxid.h>
 #include <shlib-compat.h>
 #include <nptl/pthreadP.h>
 #include <dl-sysdep.h>
@@ -139,8 +138,8 @@  __spawni_child (void *arguments)
 
   /* Set the effective user and group IDs.  */
   if ((attr->__flags & POSIX_SPAWN_RESETIDS) != 0
-      && (local_seteuid (__getuid ()) != 0
-	  || local_setegid (__getgid ())) != 0)
+      && (__seteuid (__getuid ()) != 0
+	  || __setegid (__getgid ())) != 0)
     goto fail;
 
   /* Execute the file actions.  */
diff --git a/sysdeps/unix/sysv/linux/local-setxid.h b/sysdeps/unix/sysv/linux/local-setxid.h
deleted file mode 100644
index 97d787d942..0000000000
--- a/sysdeps/unix/sysv/linux/local-setxid.h
+++ /dev/null
@@ -1,16 +0,0 @@ 
-/* SETxID functions which only have to change the local thread and
-   none of the possible other threads.  */
-#include <sysdep.h>
-
-#ifdef __NR_setresuid32
-# define local_seteuid(id) INLINE_SYSCALL (setresuid32, 3, -1, id, -1)
-#else
-# define local_seteuid(id) INLINE_SYSCALL (setresuid, 3, -1, id, -1)
-#endif
-
-
-#ifdef __NR_setresgid32
-# define local_setegid(id) INLINE_SYSCALL (setresgid32, 3, -1, id, -1)
-#else
-# define local_setegid(id) INLINE_SYSCALL (setresgid, 3, -1, id, -1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index f157bfffd2..d8623534cf 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -25,7 +25,6 @@ 
 #include <sys/param.h>
 #include <sys/mman.h>
 #include <not-cancel.h>
-#include <local-setxid.h>
 #include <shlib-compat.h>
 #include <nptl/pthreadP.h>
 #include <dl-sysdep.h>
@@ -74,6 +73,24 @@ 
 # define STACK(__stack, __stack_size) (__stack + __stack_size)
 #endif
 
+/* SETxID functions which only have to change the local thread and none of the
+   possible other threads.  */
+static int local_seteuid (uid_t euid)
+{
+#ifndef __NR_setresuid32
+# define __NR_setresuid32 __NR_setresuid
+#endif
+  return INLINE_SYSCALL_CALL (setresuid32, -1, euid, -1);
+}
+
+static int local_setegid (uid_t egid)
+{
+#ifndef __NR_setresgid32
+# define __NR_setresgid32 __NR_setresgid
+#endif
+  return INLINE_SYSCALL_CALL (setresgid32, -1, egid, -1);
+}
+
 
 struct posix_spawn_args
 {