|
|
c2dfb7 |
From 15ab55eca3d1f7feb86e55bdc147069f36d198eb Mon Sep 17 00:00:00 2001
|
|
|
c2dfb7 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
c2dfb7 |
Date: Fri, 14 Sep 2018 15:51:04 +0900
|
|
|
c2dfb7 |
Subject: [PATCH] test-fs-util: skip some tests when running in unprivileged
|
|
|
c2dfb7 |
container
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
(cherry picked from commit 9590065f37be040996f1c2b9a246b9952fdc0c0b)
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
Resolves: #1823767
|
|
|
c2dfb7 |
---
|
|
|
c2dfb7 |
src/test/test-fs-util.c | 9 ++++++++-
|
|
|
c2dfb7 |
1 file changed, 8 insertions(+), 1 deletion(-)
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
diff --git a/src/test/test-fs-util.c b/src/test/test-fs-util.c
|
|
|
c2dfb7 |
index 7b7990bb70..e3338ea440 100644
|
|
|
c2dfb7 |
--- a/src/test/test-fs-util.c
|
|
|
c2dfb7 |
+++ b/src/test/test-fs-util.c
|
|
|
c2dfb7 |
@@ -17,6 +17,7 @@
|
|
|
c2dfb7 |
#include "strv.h"
|
|
|
c2dfb7 |
#include "user-util.h"
|
|
|
c2dfb7 |
#include "util.h"
|
|
|
c2dfb7 |
+#include "virt.h"
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
static void test_chase_symlinks(void) {
|
|
|
c2dfb7 |
_cleanup_free_ char *result = NULL;
|
|
|
c2dfb7 |
@@ -468,6 +469,7 @@ static void test_touch_file(void) {
|
|
|
c2dfb7 |
struct stat st;
|
|
|
c2dfb7 |
const char *a;
|
|
|
c2dfb7 |
usec_t test_mtime;
|
|
|
c2dfb7 |
+ int r;
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
test_uid = geteuid() == 0 ? 65534 : getuid();
|
|
|
c2dfb7 |
test_gid = geteuid() == 0 ? 65534 : getgid();
|
|
|
c2dfb7 |
@@ -517,7 +519,12 @@ static void test_touch_file(void) {
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
if (geteuid() == 0) {
|
|
|
c2dfb7 |
a = strjoina(p, "/cdev");
|
|
|
c2dfb7 |
- assert_se(mknod(a, 0775 | S_IFCHR, makedev(0, 0)) >= 0);
|
|
|
c2dfb7 |
+ r = mknod(a, 0775 | S_IFCHR, makedev(0, 0));
|
|
|
c2dfb7 |
+ if (r < 0 && errno == EPERM && detect_container() > 0) {
|
|
|
c2dfb7 |
+ log_notice("Running in unprivileged container? Skipping remaining tests in %s", __func__);
|
|
|
c2dfb7 |
+ return;
|
|
|
c2dfb7 |
+ }
|
|
|
c2dfb7 |
+ assert_se(r >= 0);
|
|
|
c2dfb7 |
assert_se(touch_file(a, false, test_mtime, test_uid, test_gid, 0640) >= 0);
|
|
|
c2dfb7 |
assert_se(lstat(a, &st) >= 0);
|
|
|
c2dfb7 |
assert_se(st.st_uid == test_uid);
|