strace/0016-tests-uid-use-fchown-instead-of-chown.patch

143 lines
4.8 KiB
Diff

From 68804b326709fadc7bb03f510a11771f07216a59 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Mon, 16 Mar 2015 18:10:21 +0000
Subject: [PATCH 16/68] tests/uid*: use fchown* instead of chown*
Newer architectures have no chown syscall, so use fchown* syscalls
for testing printuid.
* tests/uid.test: Use fchown instead of chown.
* tests/uid.c: Test __NR_fchown instead of __NR_chown.
(main): Use __NR_fchown instead of __NR_chown.
* tests/uid32.c: Test __NR_fchown32 instead of __NR_chown32.
(main): Use __NR_fchown32 instead of __NR_chown32.
* tests/uid16.c: Test __NR_fchown and __NR_fchown32 instead
of __NR_chown and __NR_chown32.
(main): Use __NR_fchown instead of __NR_chown.
* tests/uid.awk: Update regexp.
---
tests/uid.awk | 6 +++---
tests/uid.c | 4 ++--
tests/uid.test | 2 +-
tests/uid16.c | 8 ++++----
tests/uid32.c | 4 ++--
5 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/tests/uid.awk b/tests/uid.awk
index c6e891a..6f07b44 100644
--- a/tests/uid.awk
+++ b/tests/uid.awk
@@ -26,9 +26,9 @@ regexp == "" {
expected = "setresuid"
regexp = "^setresuid" suffix "\\(" uid ", -1, -1\\)[[:space:]]+= 0$"
} else if (expected == "setresuid") {
- expected = "chown"
- regexp = "^chown" suffix "\\(\".\", -1, -1\\)[[:space:]]+= 0$"
- } else if (expected == "chown") {
+ expected = "fchown"
+ regexp = "^fchown" suffix "\\(1, -1, -1\\)[[:space:]]+= 0$"
+ } else if (expected == "fchown") {
expected = "1st getgroups"
regexp = "^getgroups" suffix "\\(0, NULL\\)[[:space:]]+= " r_uint "$"
} else if (expected == "1st getgroups") {
diff --git a/tests/uid.c b/tests/uid.c
index 1972044..28f548b 100644
--- a/tests/uid.c
+++ b/tests/uid.c
@@ -14,7 +14,7 @@ main(void)
&& defined(__NR_getresuid) \
&& defined(__NR_setreuid) \
&& defined(__NR_setresuid) \
- && defined(__NR_chown) \
+ && defined(__NR_fchown) \
&& defined(__NR_getgroups)
int uid;
int size;
@@ -32,7 +32,7 @@ main(void)
}
assert(syscall(__NR_setreuid, -1, -1L) == 0);
assert(syscall(__NR_setresuid, uid, -1, -1L) == 0);
- assert(syscall(__NR_chown, ".", -1, -1L) == 0);
+ assert(syscall(__NR_fchown, 1, -1, -1L) == 0);
assert((size = syscall(__NR_getgroups, 0, list)) >= 0);
assert(list = calloc(size + 1, sizeof(*list)));
assert(syscall(__NR_getgroups, size, list) == size);
diff --git a/tests/uid.test b/tests/uid.test
index f4cb8e7..d8b0261 100755
--- a/tests/uid.test
+++ b/tests/uid.test
@@ -17,7 +17,7 @@ uid="uid$s$w"
fi
}
-syscalls="getuid$s,setuid$s,getresuid$s,setreuid$s,setresuid$s,chown$s,getgroups$s"
+syscalls="getuid$s,setuid$s,getresuid$s,setreuid$s,setresuid$s,fchown$s,getgroups$s"
args="-e trace=$syscalls"
$STRACE -o "$LOG" $args ./"$uid"|| {
cat "$LOG"
diff --git a/tests/uid16.c b/tests/uid16.c
index a2006d7..c0ef120 100644
--- a/tests/uid16.c
+++ b/tests/uid16.c
@@ -15,7 +15,7 @@ main(void)
&& defined(__NR_getresuid) \
&& defined(__NR_setreuid) \
&& defined(__NR_setresuid) \
- && defined(__NR_chown) \
+ && defined(__NR_fchown) \
&& defined(__NR_getgroups) \
\
&& defined(__NR_getuid32) \
@@ -23,7 +23,7 @@ main(void)
&& defined(__NR_getresuid32) \
&& defined(__NR_setreuid32) \
&& defined(__NR_setresuid32) \
- && defined(__NR_chown32) \
+ && defined(__NR_fchown32) \
&& defined(__NR_getgroups32) \
\
&& __NR_getuid != __NR_getuid32 \
@@ -31,7 +31,7 @@ main(void)
&& __NR_getresuid != __NR_getresuid32 \
&& __NR_setreuid != __NR_setreuid32 \
&& __NR_setresuid != __NR_setresuid32 \
- && __NR_chown != __NR_chown32 \
+ && __NR_fchown != __NR_fchown32 \
&& __NR_getgroups != __NR_getgroups32 \
/**/
int uid;
@@ -65,7 +65,7 @@ main(void)
}
assert(syscall(__NR_setreuid, -1, 0xffff) == 0);
assert(syscall(__NR_setresuid, uid, -1, 0xffff) == 0);
- assert(syscall(__NR_chown, ".", -1, 0xffff) == 0);
+ assert(syscall(__NR_fchown, 1, -1, 0xffff) == 0);
assert((size = syscall(__NR_getgroups, 0, list)) >= 0);
assert(list = calloc(size + 1, sizeof(*list)));
assert(syscall(__NR_getgroups, size, list) == size);
diff --git a/tests/uid32.c b/tests/uid32.c
index 15f1202..472461f 100644
--- a/tests/uid32.c
+++ b/tests/uid32.c
@@ -14,7 +14,7 @@ main(void)
&& defined(__NR_getresuid32) \
&& defined(__NR_setreuid32) \
&& defined(__NR_setresuid32) \
- && defined(__NR_chown32) \
+ && defined(__NR_fchown32) \
&& defined(__NR_getgroups32)
int r, e, s;
int size;
@@ -25,7 +25,7 @@ main(void)
assert(syscall(__NR_getresuid32, &r, &e, &s) == 0);
assert(syscall(__NR_setreuid32, -1, -1L) == 0);
assert(syscall(__NR_setresuid32, r, -1, -1L) == 0);
- assert(syscall(__NR_chown32, ".", -1, -1L) == 0);
+ assert(syscall(__NR_fchown32, 1, -1, -1L) == 0);
assert((size = syscall(__NR_getgroups32, 0, list)) >= 0);
assert(list = calloc(size + 1, sizeof(*list)));
assert(syscall(__NR_getgroups32, size, list) == size);
--
2.3.5