summaryrefslogtreecommitdiff
path: root/vpn
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2013-03-05 14:06:20 (GMT)
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-03-08 11:09:32 (GMT)
commit48d2457887a2733c712112408886688864b76ff0 (patch)
treed401030c437fe6585c6ac0d01722bd58eb83eedc /vpn
parent800232d91504d99949ac0418c6634821235c9cd1 (diff)
downloadconnman-48d2457887a2733c712112408886688864b76ff0.zip
connman-48d2457887a2733c712112408886688864b76ff0.tar.gz
connman-48d2457887a2733c712112408886688864b76ff0.tar.bz2
vpn-provider: Do not allow changes to settings that are immutable
The immutable settings are those that are read from .config file.
Diffstat (limited to 'vpn')
-rw-r--r--vpn/vpn-provider.c29
-rw-r--r--vpn/vpn.h2
2 files changed, 26 insertions, 5 deletions
diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index 09a3d55..12c341b 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -53,6 +53,7 @@ struct vpn_route {
struct vpn_setting {
gboolean hide_value;
+ gboolean immutable;
char *value;
};
@@ -2007,7 +2008,7 @@ int __vpn_provider_create_from_config(GHashTable *settings,
g_hash_table_iter_init(&hash, settings);
while (g_hash_table_iter_next(&hash, &key, &value) == TRUE)
- vpn_provider_set_string(provider, key, value);
+ __vpn_provider_set_string_immutable(provider, key, value);
vpn_provider_save(provider);
@@ -2083,9 +2084,11 @@ const char * __vpn_provider_get_ident(struct vpn_provider *provider)
}
static int set_string(struct vpn_provider *provider,
- const char *key, const char *value, gboolean hide_value)
+ const char *key, const char *value,
+ gboolean hide_value, gboolean immutable)
{
- DBG("provider %p key %s value %s", provider, key,
+ DBG("provider %p key %s immutable %s value %s", provider, key,
+ immutable ? "yes" : "no",
hide_value ? "<not printed>" : value);
if (g_str_equal(key, "Type") == TRUE) {
@@ -2108,6 +2111,13 @@ static int set_string(struct vpn_provider *provider,
} else {
struct vpn_setting *setting;
+ setting = g_hash_table_lookup(provider->setting_strings, key);
+ if (setting != NULL && immutable == FALSE &&
+ setting->immutable == TRUE) {
+ DBG("Trying to set immutable variable %s", key);
+ return -EPERM;
+ }
+
setting = g_try_new(struct vpn_setting, 1);
if (setting == NULL)
return -ENOMEM;
@@ -2115,6 +2125,9 @@ static int set_string(struct vpn_provider *provider,
setting->value = g_strdup(value);
setting->hide_value = hide_value;
+ if (immutable == TRUE)
+ setting->immutable = TRUE;
+
if (hide_value == FALSE)
send_value(provider->path, key, setting->value);
@@ -2128,13 +2141,19 @@ static int set_string(struct vpn_provider *provider,
int vpn_provider_set_string(struct vpn_provider *provider,
const char *key, const char *value)
{
- return set_string(provider, key, value, FALSE);
+ return set_string(provider, key, value, FALSE, FALSE);
}
int vpn_provider_set_string_hide_value(struct vpn_provider *provider,
const char *key, const char *value)
{
- return set_string(provider, key, value, TRUE);
+ return set_string(provider, key, value, TRUE, FALSE);
+}
+
+int __vpn_provider_set_string_immutable(struct vpn_provider *provider,
+ const char *key, const char *value)
+{
+ return set_string(provider, key, value, FALSE, TRUE);
}
const char *vpn_provider_get_string(struct vpn_provider *provider,
diff --git a/vpn/vpn.h b/vpn/vpn.h
index c430ef5..53b117d 100644
--- a/vpn/vpn.h
+++ b/vpn/vpn.h
@@ -81,6 +81,8 @@ void __vpn_provider_list(DBusMessageIter *iter, void *user_data);
int __vpn_provider_create(DBusMessage *msg);
int __vpn_provider_create_from_config(GHashTable *settings,
const char *config_ident, const char *config_entry);
+int __vpn_provider_set_string_immutable(struct vpn_provider *provider,
+ const char *key, const char *value);
DBusMessage *__vpn_provider_get_connections(DBusMessage *msg);
const char * __vpn_provider_get_ident(struct vpn_provider *provider);
struct vpn_provider *__vpn_provider_lookup(const char *identifier);