From 37ee46f7c859cb514592eb0ff8e11fc44316ef52 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 3 Dec 2023 13:47:19 +0100 Subject: [PATCH] sysusers,tmpfiles: clarify error message for --replace I was trying to run sysusers --replace, but the input file didn't have the right suffix, and the message was very confusing. Let's split the message in two to make it clearer that we care about the extension. --- src/sysusers/sysusers.c | 8 +++++--- src/tmpfiles/tmpfiles.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index 96fb6f8ad55..19284217f7a 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -2140,10 +2140,12 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_REPLACE: - if (!path_is_absolute(optarg) || - !endswith(optarg, ".conf")) + if (!path_is_absolute(optarg)) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "The argument to --replace= must an absolute path to a config file"); + "The argument to --replace= must be an absolute path."); + if (!endswith(optarg, ".conf")) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "The argument to --replace= must have the extension '.conf'."); arg_replace = optarg; break; diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index dbe9156f067..9fc8dad3257 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -4167,10 +4167,12 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_REPLACE: - if (!path_is_absolute(optarg) || - !endswith(optarg, ".conf")) + if (!path_is_absolute(optarg)) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "The argument to --replace= must an absolute path to a config file"); + "The argument to --replace= must be an absolute path."); + if (!endswith(optarg, ".conf")) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "The argument to --replace= must have the extension '.conf'."); arg_replace = optarg; break; -- 2.47.3