1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-21 02:50:18 +03:00

hostname: accept an empty hostname to unset transient hostname

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.
This commit is contained in:
Yu Watanabe 2021-01-22 10:13:01 +09:00 committed by Zbigniew Jędrzejewski-Szmek
parent 3e405f28f4
commit f190ac486e

View 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);