summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorTopi Miettinen <toiwoton@gmail.com>2024-06-26 21:06:41 +0200
committerTopi Miettinen <topimiettinen@users.noreply.github.com>2024-07-04 11:36:04 +0200
commite81025970fed5673c631976711d45c67b0443bb4 (patch)
treed404f21b046af39007c90f96ab2ced534c901c37 /src/shared
parenttest: skip TEST-69-SHUTDOWN on Debian (diff)
downloadsystemd-e81025970fed5673c631976711d45c67b0443bb4.tar.xz
systemd-e81025970fed5673c631976711d45c67b0443bb4.zip
load-fragment: allow MountImages= with paths starting with /dev
For MountImages=, if the source is a block device, it will most likely reside in /dev. It should be also possible to mount a static device file system in place of (or part of) /dev. So let's allow paths starting with /dev as an exception for MountImages=.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/parse-helpers.c19
-rw-r--r--src/shared/parse-helpers.h11
2 files changed, 24 insertions, 6 deletions
diff --git a/src/shared/parse-helpers.c b/src/shared/parse-helpers.c
index ca6842d363..63f592d18e 100644
--- a/src/shared/parse-helpers.c
+++ b/src/shared/parse-helpers.c
@@ -10,6 +10,22 @@
#include "path-util.h"
#include "utf8.h"
+static bool validate_api_vfs(const char *path, PathSimplifyWarnFlags flags) {
+
+ assert(path);
+
+ if ((flags & (PATH_CHECK_NON_API_VFS|PATH_CHECK_NON_API_VFS_DEV_OK)) == 0)
+ return true;
+
+ if (!path_below_api_vfs(path))
+ return true;
+
+ if (FLAGS_SET(flags, PATH_CHECK_NON_API_VFS_DEV_OK) && path_startswith(path, "/dev"))
+ return true;
+
+ return false;
+}
+
int path_simplify_and_warn(
char *path,
PathSimplifyWarnFlags flags,
@@ -23,6 +39,7 @@ int path_simplify_and_warn(
assert(path);
assert(!FLAGS_SET(flags, PATH_CHECK_ABSOLUTE | PATH_CHECK_RELATIVE));
+ assert(!FLAGS_SET(flags, PATH_CHECK_NON_API_VFS | PATH_CHECK_NON_API_VFS_DEV_OK));
assert(lvalue);
if (!utf8_is_valid(path))
@@ -56,7 +73,7 @@ int path_simplify_and_warn(
"%s= path is not normalized%s: %s",
lvalue, fatal ? "" : ", ignoring", path);
- if (FLAGS_SET(flags, PATH_CHECK_NON_API_VFS) && path_below_api_vfs(path))
+ if (!validate_api_vfs(path, flags))
return log_syntax(unit, level, filename, line, SYNTHETIC_ERRNO(EINVAL),
"%s= path is below API VFS%s: %s",
lvalue, fatal ? ", refusing" : ", ignoring",
diff --git a/src/shared/parse-helpers.h b/src/shared/parse-helpers.h
index 6d1034b6de..29ab60fe9f 100644
--- a/src/shared/parse-helpers.h
+++ b/src/shared/parse-helpers.h
@@ -4,11 +4,12 @@
#include <stdint.h>
typedef enum PathSimplifyWarnFlags {
- PATH_CHECK_FATAL = 1 << 0, /* If not set, then error message is appended with 'ignoring'. */
- PATH_CHECK_ABSOLUTE = 1 << 1,
- PATH_CHECK_RELATIVE = 1 << 2,
- PATH_KEEP_TRAILING_SLASH = 1 << 3,
- PATH_CHECK_NON_API_VFS = 1 << 4,
+ PATH_CHECK_FATAL = 1 << 0, /* If not set, then error message is appended with 'ignoring'. */
+ PATH_CHECK_ABSOLUTE = 1 << 1,
+ PATH_CHECK_RELATIVE = 1 << 2,
+ PATH_KEEP_TRAILING_SLASH = 1 << 3,
+ PATH_CHECK_NON_API_VFS = 1 << 4,
+ PATH_CHECK_NON_API_VFS_DEV_OK = 1 << 5,
} PathSimplifyWarnFlags;
int path_simplify_and_warn(