main: Introduce conf file option to disable hostname updates
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Fri, 10 Aug 2012 08:21:25 +0000 (11:21 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 10 Aug 2012 14:08:28 +0000 (17:08 +0300)
The AllowHostnameUpdates in system config file can be used
to ignore the hostname update request that for example
can be received via DHCP hostname option.

src/main.c
src/main.conf

index 1e4809f..62e5c54 100644 (file)
@@ -67,6 +67,7 @@ static struct {
        unsigned int timeout_inputreq;
        unsigned int timeout_browserlaunch;
        char **blacklisted_interfaces;
+       connman_bool_t allow_hostname_updates;
 } connman_settings  = {
        .bg_scan = TRUE,
        .pref_timeservers = NULL,
@@ -76,6 +77,7 @@ static struct {
        .timeout_inputreq = DEFAULT_INPUT_REQUEST_TIMEOUT,
        .timeout_browserlaunch = DEFAULT_BROWSER_LAUNCH_TIMEOUT,
        .blacklisted_interfaces = NULL,
+       .allow_hostname_updates = TRUE,
 };
 
 static GKeyFile *load_config(const char *file)
@@ -243,6 +245,14 @@ static void parse_config(GKeyFile *config)
                        g_strdupv(default_blacklist);
 
        g_clear_error(&error);
+
+       boolean = g_key_file_get_boolean(config, "General",
+                                       "AllowHostnameUpdates",
+                                       &error);
+       if (error == NULL)
+               connman_settings.allow_hostname_updates = boolean;
+
+       g_clear_error(&error);
 }
 
 static int config_init(const char *file)
@@ -403,6 +413,9 @@ connman_bool_t connman_setting_get_bool(const char *key)
        if (g_str_equal(key, "BackgroundScanning") == TRUE)
                return connman_settings.bg_scan;
 
+       if (g_str_equal(key, "AllowHostnameUpdates") == TRUE)
+               return connman_settings.allow_hostname_updates;
+
        return FALSE;
 }
 
index 95fc7d4..67275da 100644 (file)
@@ -58,3 +58,8 @@
 # match any of the list entries. Default value is
 # vmnet,vboxnet,virbr.
 # NetworkInterfaceBlacklist = vmnet,vboxnet,virbr
+
+# Allow connman to change the system hostname. This can
+# happen for example if we receive DHCP hostname option.
+# Default value is true.
+# AllowHostnameUpdates = true