]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: port more code to generic path_simplify_and_warn()
authorLennart Poettering <lennart@poettering.net>
Mon, 19 Apr 2021 15:50:02 +0000 (17:50 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 19 Apr 2021 21:16:02 +0000 (23:16 +0200)
We have this nice helper, hence use it when parsing paths and logging
about it.

src/partition/repart.c

index 6ad12772fdd866015a09949326ac36a97e8b668d..46da0d04edc6587c78db910b09599b3921c1b1fd 100644 (file)
@@ -1139,11 +1139,9 @@ static int config_parse_copy_files(
                 return 0;
         }
 
-        if (!path_is_absolute(resolved_source) || !path_is_normalized(resolved_source)) {
-                log_syntax(unit, LOG_WARNING, filename, line, 0,
-                           "Invalid path name in CopyFiles= source, ignoring: %s", resolved_source);
+        r = path_simplify_and_warn(resolved_source, PATH_CHECK_ABSOLUTE, unit, filename, line, lvalue);
+        if (r < 0)
                 return 0;
-        }
 
         r = specifier_printf(target, specifier_table, NULL, &resolved_target);
         if (r < 0) {
@@ -1152,11 +1150,9 @@ static int config_parse_copy_files(
                 return 0;
         }
 
-        if (!path_is_absolute(resolved_target) || !path_is_normalized(resolved_target)) {
-                log_syntax(unit, LOG_WARNING, filename, line, 0,
-                           "Invalid path name in CopyFiles= source, ignoring: %s", resolved_target);
+        r = path_simplify_and_warn(resolved_target, PATH_CHECK_ABSOLUTE, unit, filename, line, lvalue);
+        if (r < 0)
                 return 0;
-        }
 
         r = strv_consume_pair(&partition->copy_files, TAKE_PTR(resolved_source), TAKE_PTR(resolved_target));
         if (r < 0)