]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfiles: move validation/normalization of path before we use it 24459/head
authorLennart Poettering <lennart@poettering.net>
Fri, 26 Aug 2022 08:12:29 +0000 (10:12 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 26 Aug 2022 09:11:48 +0000 (11:11 +0200)
We need to normalize/validate the path (i.e. first column) of
tmpfiles.d/ lines before we start using the path, otherwise we'll use it
before it's known to be good. This matters since for some line types the
path is mangled into the argument column (i.e. sevents column), and we
should only do that once we know it's in a good state.

src/tmpfiles/tmpfiles.c

index 4bbf9b4acee996a321cf0e1c2a3ba6a27b6e7e9e..8012d0d5df2f9e1d7ab42ac6239a7dcd45e0432a 100644 (file)
@@ -3082,6 +3082,14 @@ static int parse_line(
         if (r < 0)
                 return r;
 
+        if (!path_is_absolute(i.path)) {
+                *invalid_config = true;
+                return log_syntax(NULL, LOG_ERR, fname, line, SYNTHETIC_ERRNO(EBADMSG),
+                                  "Path '%s' not absolute.", i.path);
+        }
+
+        path_simplify(i.path);
+
         switch (i.type) {
 
         case CREATE_DIRECTORY:
@@ -3238,14 +3246,6 @@ static int parse_line(
                                   "Unknown command type '%c'.", (char) i.type);
         }
 
-        if (!path_is_absolute(i.path)) {
-                *invalid_config = true;
-                return log_syntax(NULL, LOG_ERR, fname, line, SYNTHETIC_ERRNO(EBADMSG),
-                                  "Path '%s' not absolute.", i.path);
-        }
-
-        path_simplify(i.path);
-
         if (!should_include_path(i.path))
                 return 0;