[RFC PATCH 2/7] tests/inject-nf.test: replace getpid with geteuid

Ákos Uzonyi uzonyi.akos at gmail.com
Mon Jun 8 19:14:47 UTC 2020


---
 tests/inject-nf.c    | 17 +++++------------
 tests/inject-nf.test | 11 +----------
 2 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/tests/inject-nf.c b/tests/inject-nf.c
index c3774f6c..2213a98c 100644
--- a/tests/inject-nf.c
+++ b/tests/inject-nf.c
@@ -16,28 +16,21 @@
 
 #include "raw_syscall.h"
 
-#ifdef __alpha__
-/* alpha has no getpid */
-# define SC_NR __NR_getpgrp
-# define SC_NAME "getpgrp"
-# define getpid getpgrp
-#else
-# define SC_NR __NR_getpid
-# define SC_NAME "getpid"
-#endif
+#define SC_NR __NR_geteuid
+#define SC_NAME "geteuid"
 
 #ifdef raw_syscall_0
 # define INVOKE_SC(err) raw_syscall_0(SC_NR, &err)
 #else
 /* No raw_syscall_0, let's use getpid() and hope for the best.  */
-# define INVOKE_SC(err) getpid()
+# define INVOKE_SC(err) geteuid()
 #endif
 
 /*
  * This prototype is intentionally different
  * from the prototype provided by <unistd.h>.
  */
-extern kernel_ulong_t getpid(void);
+extern kernel_ulong_t geteuid(void);
 
 int
 main(int ac, char **av)
@@ -45,7 +38,7 @@ main(int ac, char **av)
 	assert(ac == 1 || ac == 2);
 
 	kernel_ulong_t expected =
-		(ac == 1) ? getpid() : strtoull(av[1], NULL, 0);
+		(ac == 1) ? geteuid() : strtoull(av[1], NULL, 0);
 	kernel_ulong_t err = 0;
 	kernel_ulong_t rc = INVOKE_SC(err);
 
diff --git a/tests/inject-nf.test b/tests/inject-nf.test
index cadb5adb..74ea3374 100755
--- a/tests/inject-nf.test
+++ b/tests/inject-nf.test
@@ -9,18 +9,9 @@
 
 . "${srcdir=.}/scno_tampering.sh"
 
-case "$STRACE_ARCH" in
-alpha)
-	SYSCALL=getpgrp
-	;;
-*)
-	SYSCALL=getpid
-	;;
-esac
-
 run_prog
 prog="$args"
-fault_args="-a9 -e trace=${SYSCALL} -e inject=${SYSCALL}:retval="
+fault_args="-a9 -e trace=geteuid -e inject=geteuid:retval="
 
 test_rval()
 {
-- 
2.26.2



More information about the Strace-devel mailing list