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