daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
b8c242
From e61aa66a63bcfe9ce0d80f0db691ba40218b872a Mon Sep 17 00:00:00 2001
b8c242
From: Lennart Poettering <lennart@poettering.net>
b8c242
Date: Fri, 14 Aug 2020 21:50:55 +0200
b8c242
Subject: [PATCH] test: accept that char device 0/0 can now be created witout
b8c242
 privileges
b8c242
b8c242
Fixes: #16721
b8c242
(cherry picked from commit 5b5ce6298e5a1c09beacd5c963e2350979cbf94a)
b8c242
b8c242
Related: #2017033
b8c242
---
b8c242
 src/test/test-fs-util.c | 12 ++++++------
b8c242
 1 file changed, 6 insertions(+), 6 deletions(-)
b8c242
b8c242
diff --git a/src/test/test-fs-util.c b/src/test/test-fs-util.c
b8c242
index e3338ea440..aa32629f62 100644
b8c242
--- a/src/test/test-fs-util.c
b8c242
+++ b/src/test/test-fs-util.c
b8c242
@@ -518,8 +518,8 @@ static void test_touch_file(void) {
b8c242
         assert_se(timespec_load(&st.st_mtim) == test_mtime);
b8c242
 
b8c242
         if (geteuid() == 0) {
b8c242
-                a = strjoina(p, "/cdev");
b8c242
-                r = mknod(a, 0775 | S_IFCHR, makedev(0, 0));
b8c242
+                a = strjoina(p, "/bdev");
b8c242
+                r = mknod(a, 0775 | S_IFBLK, makedev(0, 0));
b8c242
                 if (r < 0 && errno == EPERM && detect_container() > 0) {
b8c242
                         log_notice("Running in unprivileged container? Skipping remaining tests in %s", __func__);
b8c242
                         return;
b8c242
@@ -529,17 +529,17 @@ static void test_touch_file(void) {
b8c242
                 assert_se(lstat(a, &st) >= 0);
b8c242
                 assert_se(st.st_uid == test_uid);
b8c242
                 assert_se(st.st_gid == test_gid);
b8c242
-                assert_se(S_ISCHR(st.st_mode));
b8c242
+                assert_se(S_ISBLK(st.st_mode));
b8c242
                 assert_se((st.st_mode & 0777) == 0640);
b8c242
                 assert_se(timespec_load(&st.st_mtim) == test_mtime);
b8c242
 
b8c242
-                a = strjoina(p, "/bdev");
b8c242
-                assert_se(mknod(a, 0775 | S_IFBLK, makedev(0, 0)) >= 0);
b8c242
+                a = strjoina(p, "/cdev");
b8c242
+                assert_se(mknod(a, 0775 | S_IFCHR, makedev(0, 0)) >= 0);
b8c242
                 assert_se(touch_file(a, false, test_mtime, test_uid, test_gid, 0640) >= 0);
b8c242
                 assert_se(lstat(a, &st) >= 0);
b8c242
                 assert_se(st.st_uid == test_uid);
b8c242
                 assert_se(st.st_gid == test_gid);
b8c242
-                assert_se(S_ISBLK(st.st_mode));
b8c242
+                assert_se(S_ISCHR(st.st_mode));
b8c242
                 assert_se((st.st_mode & 0777) == 0640);
b8c242
                 assert_se(timespec_load(&st.st_mtim) == test_mtime);
b8c242
         }