config: Default config protection set to TRUE
authorSamuel Ortiz <sameo@linux.intel.com>
Mon, 11 Apr 2011 10:01:00 +0000 (12:01 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 11 Apr 2011 10:02:46 +0000 (12:02 +0200)
Configs will be protected, unless explicitely set otherwise.

doc/config-format.txt
src/config.c

index 7f23c76..cf89c09 100644 (file)
@@ -17,8 +17,8 @@ The 2 allowed fields for that entry are:
 - Name: Name of the network.
 - Description: Description of the network.
 - Protected: Configuration protection against being removed, modified or
-overwritten by a Manager.ProvisionService() call. By default, a configuration
-is not protected.
+overwritten by a Manager.ProvisionService() call. If unset, this value defaults
+to TRUE, i.e. configs are protected by default.
 
 
 Service entry [service_*]
index a0872f7..53f9ad0 100644 (file)
@@ -373,6 +373,7 @@ err:
 static int load_config(struct connman_config *config)
 {
        GKeyFile *keyfile;
+       GError *error = NULL;
        gsize length;
        char **groups;
        char *str;
@@ -401,8 +402,11 @@ static int load_config(struct connman_config *config)
        }
 
        protected = g_key_file_get_boolean(keyfile, "global",
-                                       CONFIG_KEY_PROT, NULL);
-       config->protected = protected;
+                                       CONFIG_KEY_PROT, &error);
+       if (error == NULL)
+               config->protected = protected;
+       else
+               config->protected = TRUE;
 
        groups = g_key_file_get_groups(keyfile, &length);
 
@@ -478,6 +482,7 @@ int __connman_config_load_service(GKeyFile *keyfile, const char *group,
                                                        service_name);
        g_key_file_set_string(keyfile, "global", CONFIG_KEY_DESC,
                                                "Internal Config File");
+       g_key_file_set_boolean(keyfile, "global", CONFIG_KEY_PROT, FALSE);
 
        content = g_key_file_to_data(keyfile, &content_length, NULL);
        if (content == NULL) {