]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
firstboot: allow a trailing dot on fqdn
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 28 Jul 2015 02:20:46 +0000 (22:20 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 6 Aug 2015 00:49:20 +0000 (20:49 -0400)
src/firstboot/firstboot.c

index 43669d28bf0d0aa6fb35d40f272a0c51b3e7cd5f..df98212da843c335077284f2cebc94e2a415d49a 100644 (file)
@@ -386,12 +386,13 @@ static int prompt_hostname(void) {
                         break;
                 }
 
-                if (!hostname_is_valid(h, false)) {
+                if (!hostname_is_valid(h, true)) {
                         log_error("Specified hostname invalid.");
                         continue;
                 }
 
-                arg_hostname = h;
+                /* Get rid of the trailing dot that we allow, but don't want to see */
+                arg_hostname = hostname_cleanup(h, false);
                 h = NULL;
                 break;
         }
@@ -780,11 +781,12 @@ static int parse_argv(int argc, char *argv[]) {
                         break;
 
                 case ARG_HOSTNAME:
-                        if (!hostname_is_valid(optarg, false)) {
+                        if (!hostname_is_valid(optarg, true)) {
                                 log_error("Host name %s is not valid.", optarg);
                                 return -EINVAL;
                         }
 
+                        hostname_cleanup(optarg, false);
                         if (free_and_strdup(&arg_hostname, optarg) < 0)
                                 return log_oom();