ryantimwilson / rpms / systemd

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