From: Yu Watanabe Date: Fri, 22 Jan 2021 01:13:01 +0000 (+0900) Subject: hostname: accept an empty hostname to unset transient hostname X-Git-Tag: v248-rc1~274 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f190ac486e34ac6b35ef8a54b3d8212c25de7821;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index d797324783f..35c2c37f924 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -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);