[PATCH] Fix where network manager generating invalid /etc/hosts file



Currently Network Manger will generate an invalid /etc/hosts file in the
fail case where it cannot properly update it.

This is the /etc/hosts you get:
http://launchpadlibrarian.net/34976783/hosts

We notice this (still trying to figure out how managed to get into this
situation) here:
https://bugs.launchpad.net/oem-priority/+bug/471498


Signed-off-by: Jerone Young <jerone young canononical com>

diff --git a/src/NetworkManagerPolicy.c b/src/NetworkManagerPolicy.c
index 5b860aa..5c5ae40 100644
--- a/src/NetworkManagerPolicy.c
+++ b/src/NetworkManagerPolicy.c
@@ -315,9 +315,9 @@ update_etc_hosts (const char *hostname)
 
 	/* Hmm, /etc/hosts was empty for some reason */
 	if (!added) {
-		g_string_append (new_contents, "# Do not remove the following line, or various programs");
-		g_string_append (new_contents, "# that require network functionality will fail.");
-		g_string_append (new_contents, "127.0.0.1\t" FALLBACK_HOSTNAME "\tlocalhost");
+		g_string_append (new_contents, "# Do not remove the following line, or various programs\n");
+		g_string_append (new_contents, "# that require network functionality will fail.\n");
+		g_string_append (new_contents, "127.0.0.1\t" FALLBACK_HOSTNAME "\tlocalhost\n");
 	}
 
 	error = NULL;




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]