From f190ac486e34ac6b35ef8a54b3d8212c25de7821 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 22 Jan 2021 10:13:01 +0900 Subject: [PATCH] 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. --- src/hostname/hostnamed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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);