]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-fs-util: skip encrypted path test if we get EACCES
authorTopi Miettinen <toiwoton@gmail.com>
Mon, 17 Aug 2020 09:08:57 +0000 (12:08 +0300)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 17 Aug 2020 16:30:24 +0000 (18:30 +0200)
Unprivileged test-fs-util fails on my system since /sys/dev/block is
inaccessible for unprivileged users, so let's skip encrypted path test if we
get EACCES or similar.

src/test/test-fs-util.c

index dfea70ca27390a4bcfa504f1d695ef8c2db2a175..1ea845dd9bd7109463c198cd9fc4e921cabb77fc 100644 (file)
@@ -850,11 +850,12 @@ static void test_path_is_encrypted_one(const char *p, int expect) {
         int r;
 
         r = path_is_encrypted(p);
-        if (r == -ENOENT) /* This might fail, if btrfs is used and we run in a container. In that case we
-                           * cannot resolve the device node paths that BTRFS_IOC_DEV_INFO returns, because
-                           * the device nodes are unlikely to exist in the container. But if we can't stat()
-                           * them we cannot determine the dev_t of them, and thus cannot figure out if they
-                           * are enrypted. Hence let's just ignore ENOENT here. */
+        if (r == -ENOENT || ERRNO_IS_PRIVILEGE(r)) /* This might fail, if btrfs is used and we run in a
+                           * container. In that case we cannot resolve the device node paths that
+                           * BTRFS_IOC_DEV_INFO returns, because the device nodes are unlikely to exist in
+                           * the container. But if we can't stat() them we cannot determine the dev_t of
+                           * them, and thus cannot figure out if they are enrypted. Hence let's just ignore
+                           * ENOENT here. Also skip the test if we lack privileges. */
                 return;
         assert_se(r >= 0);