diff options
author | Jiří Klimeš <jklimes@redhat.com> | 2014-03-26 16:23:54 +0100 |
---|---|---|
committer | Jiří Klimeš <jklimes@redhat.com> | 2014-03-31 15:14:14 +0200 |
commit | bcb253b1939243f29540c00a0ff67d9f1bcf1749 (patch) | |
tree | 8cdbea5abbac9bb5a96837dd8f263b32edc4aa05 | |
parent | f35407154ae735f3331b1d735440c5c427cbe438 (diff) | |
download | NetworkManager-jk/rh1070829-hostname-selinux.tar.gz |
ifcfg-rh: put \n after hostname when writing it to /etc/hostnamejk/rh1070829-hostname-selinux
-rw-r--r-- | src/settings/plugins/ifcfg-rh/plugin.c | 6 |
1 files changed, 5 insertions, 1 deletions
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); |