richardphibel / rpms / systemd

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