]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hostname: accept an empty hostname to unset transient hostname
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 22 Jan 2021 01:13:01 +0000 (10:13 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 22 Jan 2021 06:40:26 +0000 (07:40 +0100)
Follow-up for 60e4fb4240b24bdd2d4299d8d844f48093df8807.

Before 60e4fb4240b24bdd2d4299d8d844f48093df8807,
`hostnamectl --transient set-hostname ""` unsets the transient hostname.
But after the commit, it is refused. This fixes the issue.

src/hostname/hostnamed.c

index d797324783f3e57240bad87d71214d11b81f12dd..35c2c37f92435056b87d5b5c2c263a346f1b3602 100644 (file)
@@ -693,7 +693,7 @@ static int method_set_hostname(sd_bus_message *m, void *userdata, sd_bus_error *
         /* We always go through with the procedure below without comparing to the current hostname, because
          * we might want to adjust hostname source information even if the actual hostname is unchanged. */
 
-        if (!hostname_is_valid(name, 0))
+        if (name && !hostname_is_valid(name, 0))
                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid hostname '%s'", name);
 
         context_read_etc_hostname(c);