From bcb253b1939243f29540c00a0ff67d9f1bcf1749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Wed, 26 Mar 2014 16:23:54 +0100 Subject: ifcfg-rh: put \n after hostname when writing it to /etc/hostname --- src/settings/plugins/ifcfg-rh/plugin.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index ca92606630..317c1bfdc9 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -673,6 +673,7 @@ plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname) { SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); shvarFile *network; + char *hostname_eol; gboolean ret; #if HAVE_SELINUX security_context_t se_ctx_prev, se_ctx = NULL; @@ -686,7 +687,8 @@ plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname) setfscreatecon (se_ctx); #endif - ret = g_file_set_contents (HOSTNAME_FILE, hostname, -1, NULL); + hostname_eol = g_strdup_printf ("%s\n", hostname); + ret = g_file_set_contents (HOSTNAME_FILE, hostname_eol, -1, NULL); #if HAVE_SELINUX /* Restore previous context and cleanup */ @@ -697,11 +699,13 @@ plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname) if (!ret) { PLUGIN_WARN (IFCFG_PLUGIN_NAME, "Could not save hostname: failed to create/open " HOSTNAME_FILE); + g_free (hostname_eol); return FALSE; } g_free (priv->hostname); priv->hostname = g_strdup (hostname); + g_free (hostname_eol); /* Remove "HOSTNAME" from SC_NETWORK_FILE, if present */ network = svNewFile (SC_NETWORK_FILE); -- cgit v1.2.1