From e724b0639c43c2821613fc4f7f755f87c49a22e8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 7 May 2013 20:55:11 +0200 Subject: hostname: only suppress setting of pretty hostname if it is non-equal to the static hostname and if the static hostname is set, too https://bugzilla.redhat.com/show_bug.cgi?id=957814 --- src/hostname/hostnamectl.c | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) (limited to 'src/hostname') diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c index 1c9043534a..a1e1bd8443 100644 --- a/src/hostname/hostnamectl.c +++ b/src/hostname/hostnamectl.c @@ -213,26 +213,6 @@ static int show_status(DBusConnection *bus, char **args, unsigned n) { return 0; } -static char* hostname_simplify(char *s) { - char *p, *d; - - for (p = s, d = s; *p; p++) { - if ((*p >= 'a' && *p <= 'z') || - (*p >= '0' && *p <= '9') || - *p == '-' || *p == '_') - *(d++) = *p; - else if (*p >= 'A' && *p <= 'Z') - *(d++) = *p - 'A' + 'a'; - else if (*p == ' ') - *(d++) = '-'; - } - - *d = 0; - - strshorten(s, HOST_NAME_MAX); - return s; -} - static int set_hostname(DBusConnection *bus, char **args, unsigned n) { _cleanup_dbus_message_unref_ DBusMessage *reply = NULL; dbus_bool_t interactive = true; @@ -254,16 +234,17 @@ static int set_hostname(DBusConnection *bus, char **args, unsigned n) { * just set the passed hostname as static/dynamic * hostname. */ - if (hostname_is_valid(hostname)) + h = strdup(hostname); + if (!h) + return log_oom(); + + hostname_cleanup(h, true); + + if (arg_set_static && streq(h, hostname)) p = ""; else { p = hostname; - - h = strdup(hostname); - if (!h) - return log_oom(); - - hostname = hostname_simplify(h); + hostname = h; } r = bus_method_call_with_reply( -- cgit v1.2.3-54-g00ecf