Add support for setting default hostname
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 23 Apr 2009 11:10:51 +0000 (12:10 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 23 Apr 2009 11:10:51 +0000 (12:10 +0100)
plugins/loopback.c

index 7225812..782853e 100644 (file)
@@ -136,6 +136,14 @@ static void remove_watch(void)
 }
 #endif
 
+static void create_hostname(void)
+{
+       const char *name = "localhost";
+
+       if (sethostname(name, strlen(name)) < 0)
+               connman_error("Failed to set hostname to %s", name);
+}
+
 static int setup_hostname(void)
 {
        char name[HOST_NAME_MAX + 1];
@@ -149,6 +157,8 @@ static int setup_hostname(void)
 
        if (strlen(name) > 0 && strcmp(name, "(none)") != 0)
                connman_info("System hostname is %s", name);
+       else
+               create_hostname();
 
        memset(name, 0, sizeof(name));