summaryrefslogtreecommitdiff
path: root/src/hostname/hostnamectl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-05-07 20:55:11 +0200
committerLennart Poettering <lennart@poettering.net>2013-05-07 20:56:41 +0200
commite724b0639c43c2821613fc4f7f755f87c49a22e8 (patch)
tree1c981e6dd6521cd1188abb3ab2536279b5bc3747 /src/hostname/hostnamectl.c
parent0b95a21bd70f63fc57f62020ae84e467712d69f2 (diff)
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
Diffstat (limited to 'src/hostname/hostnamectl.c')
-rw-r--r--src/hostname/hostnamectl.c35
1 files changed, 8 insertions, 27 deletions
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(