LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File ensure-shortname-is-set-as-hostname-bnc-820213.patch of Package systemd (Project Base:System)

From: Frederic Crozat <fcrozat@suse.com>
Date: Tue, 28 May 2013 15:17:35 +0200
Subject: ensure shortname is set as hostname (bnc#820213)

strip hostname so the domain part isn't set as part of the hostname
---
 src/core/hostname-setup.c |    4 ++++
 1 file changed, 4 insertions(+)

Index: systemd-221/src/core/hostname-setup.c
===================================================================
--- systemd-221.orig/src/core/hostname-setup.c
+++ systemd-221/src/core/hostname-setup.c
@@ -34,6 +34,7 @@ int hostname_setup(void) {
         int r;
         _cleanup_free_ char *b = NULL;
         const char *hn;
+        char *domain;
         bool enoent = false;
 
         r = read_hostname_config("/etc/hostname", &b);
@@ -46,6 +47,9 @@ int hostname_setup(void) {
                 hn = NULL;
         } else
                 hn = b;
+        /* strip any leftover of a domain name */
+        if ((domain = strchr(hn, '.')) != NULL)
+                *domain = '\0';
 
         if (isempty(hn)) {
                 /* Don't override the hostname if it is already set