From 0ade2213e6a515f30dd587d9378958675e0ea245 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 19 Apr 2021 17:50:02 +0200 Subject: [PATCH] repart: port more code to generic path_simplify_and_warn() We have this nice helper, hence use it when parsing paths and logging about it. --- src/partition/repart.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/partition/repart.c b/src/partition/repart.c index 6ad12772fd..46da0d04ed 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -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)