From 52ef5dd7989d886945e18ab50de31bf5a21ba158 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 11 Dec 2020 16:40:45 +0100 Subject: hostname-util: flagsify hostname_is_valid(), drop machine_name_is_valid() Let's clean up hostname_is_valid() a bit: let's turn the second boolean argument into a more explanatory flags field, and add a flag that accepts the special name ".host" as valid. This is useful for the container logic, where the special hostname ".host" refers to the "root container", i.e. the host system itself, and can be specified at various places. let's also get rid of machine_name_is_valid(). It was just an alias, which is confusing and even more so now that we have the flags param. --- src/firstboot/firstboot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/firstboot/firstboot.c') diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index 742b43f9fc..48baae3f89 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -493,7 +493,7 @@ static int prompt_hostname(void) { break; } - if (!hostname_is_valid(h, true)) { + if (!hostname_is_valid(h, VALID_HOSTNAME_TRAILING_DOT)) { log_error("Specified hostname invalid."); continue; } @@ -1135,7 +1135,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_HOSTNAME: - if (!hostname_is_valid(optarg, true)) + if (!hostname_is_valid(optarg, VALID_HOSTNAME_TRAILING_DOT)) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Host name %s is not valid.", optarg); -- cgit v1.2.1