Skip to content

Commit

Permalink
test: accept that char device 0/0 can now be created witout privileges
Browse files Browse the repository at this point in the history
  • Loading branch information
poettering authored and keszybz committed Aug 17, 2020
1 parent 340e193 commit 5b5ce62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/test/test-fs-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@ static void test_touch_file(void) {
assert_se(timespec_load(&st.st_mtim) == test_mtime);

if (geteuid() == 0) {
a = strjoina(p, "/cdev");
r = mknod(a, 0775 | S_IFCHR, makedev(0, 0));
a = strjoina(p, "/bdev");
r = mknod(a, 0775 | S_IFBLK, makedev(0, 0));
if (r < 0 && errno == EPERM && detect_container() > 0) {
log_notice("Running in unprivileged container? Skipping remaining tests in %s", __func__);
return;
Expand All @@ -626,17 +626,17 @@ static void test_touch_file(void) {
assert_se(lstat(a, &st) >= 0);
assert_se(st.st_uid == test_uid);
assert_se(st.st_gid == test_gid);
assert_se(S_ISCHR(st.st_mode));
assert_se(S_ISBLK(st.st_mode));
assert_se((st.st_mode & 0777) == 0640);
assert_se(timespec_load(&st.st_mtim) == test_mtime);

a = strjoina(p, "/bdev");
assert_se(mknod(a, 0775 | S_IFBLK, makedev(0, 0)) >= 0);
a = strjoina(p, "/cdev");
assert_se(mknod(a, 0775 | S_IFCHR, makedev(0, 0)) >= 0);
assert_se(touch_file(a, false, test_mtime, test_uid, test_gid, 0640) >= 0);
assert_se(lstat(a, &st) >= 0);
assert_se(st.st_uid == test_uid);
assert_se(st.st_gid == test_gid);
assert_se(S_ISBLK(st.st_mode));
assert_se(S_ISCHR(st.st_mode));
assert_se((st.st_mode & 0777) == 0640);
assert_se(timespec_load(&st.st_mtim) == test_mtime);
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/test-stat-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static void test_device_path_make_canonical(void) {
test_device_path_make_canonical_one("/dev/urandom");
test_device_path_make_canonical_one("/dev/tty");

if (is_device_node("/run/systemd/inaccessible/chr") > 0) {
if (is_device_node("/run/systemd/inaccessible/blk") > 0) {
test_device_path_make_canonical_one("/run/systemd/inaccessible/chr");
test_device_path_make_canonical_one("/run/systemd/inaccessible/blk");
}
Expand Down

0 comments on commit 5b5ce62

Please sign in to comment.