Comment 9 for bug 471498

Revision history for this message
Mario Limonciello (superm1) wrote :

So two things worth mentioning:

1) This can't be reproduced 100% of the time, but when it does happen, the results on the system are disastrous.

2) That /etc/hosts bares an uncanny similarity to the one that NetworkManager would normally generate if it encountered an empty /etc/hosts. So there looks to be two bugs at play.
  a) There looks to be a bug with that in that no new lines are spit out by Network Manager
  b) If Network Manager calls update_etc_hosts at the exact same time that oem-config was changing the hostname, you can run into this scenario. OEM-config shouldn't be changing the hostname at all in the first place though as there is no place in the UI to set it.

here's a snippet from src/NetworkManagerPolicy.c:

        /* 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");
        }

        error = NULL;
        if (!g_file_set_contents (SYSCONFDIR "/hosts", new_contents->str, -1, &error)) {
                nm_warning ("%s: couldn't update " SYSCONFDIR "/hosts: (%d) %s",
                            __func__, error ? error->code : 0,
                            (error && error->message) ? error->message : "(unknown)");
                if (error)
                        g_error_free (error);
        } else
                success = TRUE;

        g_string_free (new_contents, TRUE);
        return success;