Re: Should we fallback to localhost.localdomain when failed to update /etc/hosts?

Here's the patch. Could anyone please tell me if this will be fixed upstream?

On Thu, Nov 18, 2010 at 8:59 PM, Mu Qiao <qiaomuf gmail com> wrote:

I see a user has an read-only /etc directory. When he uses NM and
obtains address via DHCP, the hostname will finally be changed to
localhost.localdomain which is not what he wants.

I find in nm-policy-hostname.c that we will fallback to
localhost.localdomain if we failed to update /etc/hosts. But according
to the case above, I think this is not what we want.

Mu Qiao
GnuPG fingerprint: 92B1 B0C4 8D14 F8C4 EFA5 3ACC 30B3 0DE4 17B1 57E9

Best wishes,
Mu Qiao
GnuPG fingerprint: 92B1 B0C4 8D14 F8C4 EFA5  3ACC 30B3 0DE4 17B1 57E9
diff --git a/src/nm-policy-hostname.c b/src/nm-policy-hostname.c
index 42a2e0f..e72eff2 100644
--- a/src/nm-policy-hostname.c
+++ b/src/nm-policy-hostname.c
@@ -265,13 +265,8 @@ nm_policy_set_system_hostname (const char *new_hostname,
 	                                       &changed)) {
-		/* error updating /etc/hosts; fallback to localhost.localdomain */
-		nm_log_info (LOGD_DNS, "Setting system hostname to '" FALLBACK_HOSTNAME4 "' (error updating /etc/hosts)");
-		ret = sethostname (FALLBACK_HOSTNAME4, strlen (FALLBACK_HOSTNAME4));
-		if (ret != 0) {
-			nm_log_warn (LOGD_DNS, "couldn't set the fallback system hostname (%s): (%d) %s",
-			             FALLBACK_HOSTNAME4, errno, strerror (errno));
-		}
+		/* error updating /etc/hosts; */
+		nm_log_info (LOGD_DNS, "Error updating /etc/hosts");
 	return changed;

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