Commit a2597c08 authored by Jiří Klimeš's avatar Jiří Klimeš
Browse files

ifcfg-rh: put \n after hostname when writing it to /etc/hostname

parent da354830
......@@ -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;
security_context_t se_ctx_prev, se_ctx = NULL;
......@@ -686,7 +687,8 @@ plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname)
setfscreatecon (se_ctx);
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);
/* 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);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment