mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-24 11:16:51 +00:00
connman: add upstream patches (squashed)
- connman-do-not-allow-changes-if-immutable.patch - connman-do-not-load-immutable-vpn-connections.patch - connman-function-to-set-immutable-flag.patch - connman-intoduce-immutable-flag-to-provider-data.patch - connman-provisioned-vpn-connections-are-immutable.patch - connman-rememver-the-immutable-flag.patch - connman-send-signal-only-if-immutable-changes.patch - connman-set-immutable-flag-of-the-vpn-service.patch - connman-setproperty-clearproperty-does-not-wor-on-immutable.patch
This commit is contained in:
parent
d1ccd21e5f
commit
2d2cfd8f9e
270
packages/network/connman/patches/connman-immutable.patch
Normal file
270
packages/network/connman/patches/connman-immutable.patch
Normal file
@ -0,0 +1,270 @@
|
||||
diff --git a/doc/vpn-connection-api.txt b/doc/vpn-connection-api.txt
|
||||
index 722d708..4367699 100644
|
||||
--- a/doc/vpn-connection-api.txt
|
||||
+++ b/doc/vpn-connection-api.txt
|
||||
@@ -75,6 +75,14 @@ Properties string State [readonly]
|
||||
|
||||
The VPN host (server) address.
|
||||
|
||||
+ boolean Immutable [readonly]
|
||||
+
|
||||
+ This value will be set to true if the connection is
|
||||
+ configured externally via a configuration file.
|
||||
+
|
||||
+ The only valid operation are Connect(), Disconnect()
|
||||
+ and GetProperties()
|
||||
+
|
||||
int Index [readonly]
|
||||
|
||||
The index of the VPN network tunneling interface.
|
||||
diff --git a/include/provider.h b/include/provider.h
|
||||
index c9a3b91..bfefaed 100644
|
||||
--- a/include/provider.h
|
||||
+++ b/include/provider.h
|
||||
@@ -101,6 +101,8 @@ int connman_provider_set_ipaddress(struct connman_provider *provider,
|
||||
int connman_provider_set_pac(struct connman_provider *provider,
|
||||
const char *pac);
|
||||
int connman_provider_create_service(struct connman_provider *provider);
|
||||
+int connman_provider_set_immutable(struct connman_provider *provider,
|
||||
+ connman_bool_t immutable);
|
||||
struct connman_provider *connman_provider_get(const char *identifier);
|
||||
void connman_provider_put(struct connman_provider *provider);
|
||||
int connman_provider_set_domain(struct connman_provider *provider,
|
||||
diff --git a/plugins/vpn.c b/plugins/vpn.c
|
||||
index d27346a..cbba396 100644
|
||||
--- a/plugins/vpn.c
|
||||
+++ b/plugins/vpn.c
|
||||
@@ -81,6 +81,7 @@ struct connection_data {
|
||||
char **host_ip;
|
||||
char *domain;
|
||||
char **nameservers;
|
||||
+ gboolean immutable;
|
||||
|
||||
GHashTable *server_routes;
|
||||
GHashTable *user_routes;
|
||||
@@ -300,6 +301,7 @@ static int create_provider(struct connection_data *data, void *user_data)
|
||||
|
||||
err = connman_provider_create_service(data->provider);
|
||||
if (err == 0) {
|
||||
+ connman_provider_set_immutable(data->provider, data->immutable);
|
||||
if (g_str_equal(data->state, "ready") == TRUE) {
|
||||
connman_provider_set_index(data->provider,
|
||||
data->index);
|
||||
@@ -599,6 +601,8 @@ static void add_connection(const char *path, DBusMessageIter *properties,
|
||||
} else if (g_str_equal(key, "Type") == TRUE) {
|
||||
dbus_message_iter_get_basic(&value, &str);
|
||||
data->type = g_strdup(str);
|
||||
+ } else if (g_str_equal(key, "Immutable") == TRUE) {
|
||||
+ dbus_message_iter_get_basic(&value, &data->immutable);
|
||||
} else if (g_str_equal(key, "Host") == TRUE) {
|
||||
dbus_message_iter_get_basic(&value, &str);
|
||||
data->host = g_strdup(str);
|
||||
diff --git a/src/provider.c b/src/provider.c
|
||||
index fa3bc48..ca86880 100644
|
||||
--- a/src/provider.c
|
||||
+++ b/src/provider.c
|
||||
@@ -334,6 +334,19 @@ int connman_provider_create_service(struct connman_provider *provider)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+int connman_provider_set_immutable(struct connman_provider *provider,
|
||||
+ connman_bool_t immutable)
|
||||
+{
|
||||
+ if (provider == NULL)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ if (provider->vpn_service == NULL)
|
||||
+ return -ESRCH;
|
||||
+
|
||||
+ return __connman_service_set_immutable(provider->vpn_service,
|
||||
+ immutable);
|
||||
+}
|
||||
+
|
||||
static struct connman_provider *provider_lookup(const char *identifier)
|
||||
{
|
||||
return g_hash_table_lookup(provider_hash, identifier);
|
||||
diff --git a/src/service.c b/src/service.c
|
||||
index 4dfc86b..a1b7b94 100644
|
||||
--- a/src/service.c
|
||||
+++ b/src/service.c
|
||||
@@ -4712,6 +4712,10 @@ int __connman_service_set_immutable(struct connman_service *service,
|
||||
{
|
||||
if (service->hidden == TRUE)
|
||||
return -EOPNOTSUPP;
|
||||
+
|
||||
+ if (service->immutable == immutable)
|
||||
+ return 0;
|
||||
+
|
||||
service->immutable = immutable;
|
||||
|
||||
immutable_changed(service);
|
||||
diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
|
||||
index 40450eb..0c23188 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;
|
||||
};
|
||||
|
||||
@@ -82,6 +83,7 @@ struct vpn_provider {
|
||||
guint notify_id;
|
||||
char *config_file;
|
||||
char *config_entry;
|
||||
+ connman_bool_t immutable;
|
||||
};
|
||||
|
||||
static void append_properties(DBusMessageIter *iter,
|
||||
@@ -406,6 +408,9 @@ static DBusMessage *set_property(DBusConnection *conn, DBusMessage *msg,
|
||||
|
||||
DBG("conn %p", conn);
|
||||
|
||||
+ if (provider->immutable == TRUE)
|
||||
+ return __connman_error_not_supported(msg);
|
||||
+
|
||||
if (dbus_message_iter_init(msg, &iter) == FALSE)
|
||||
return __connman_error_invalid_arguments(msg);
|
||||
|
||||
@@ -456,6 +461,9 @@ static DBusMessage *clear_property(DBusConnection *conn, DBusMessage *msg,
|
||||
|
||||
DBG("conn %p", conn);
|
||||
|
||||
+ if (provider->immutable == TRUE)
|
||||
+ return __connman_error_not_supported(msg);
|
||||
+
|
||||
dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &name,
|
||||
DBUS_TYPE_INVALID);
|
||||
|
||||
@@ -826,7 +834,16 @@ static int vpn_provider_save(struct vpn_provider *provider)
|
||||
{
|
||||
GKeyFile *keyfile;
|
||||
|
||||
- DBG("provider %p", provider);
|
||||
+ DBG("provider %p immutable %s", provider,
|
||||
+ provider->immutable ? "yes" : "no");
|
||||
+
|
||||
+ if (provider->immutable == TRUE) {
|
||||
+ /*
|
||||
+ * Do not save providers that are provisioned via .config
|
||||
+ * file.
|
||||
+ */
|
||||
+ return -EPERM;
|
||||
+ }
|
||||
|
||||
keyfile = g_key_file_new();
|
||||
if (keyfile == NULL)
|
||||
@@ -1341,6 +1358,9 @@ static void append_properties(DBusMessageIter *iter,
|
||||
connman_dbus_dict_append_basic(&dict, "Domain",
|
||||
DBUS_TYPE_STRING, &provider->domain);
|
||||
|
||||
+ connman_dbus_dict_append_basic(&dict, "Immutable", DBUS_TYPE_BOOLEAN,
|
||||
+ &provider->immutable);
|
||||
+
|
||||
if (provider->family == AF_INET)
|
||||
connman_dbus_dict_append_dict(&dict, "IPv4", append_ipv4,
|
||||
provider);
|
||||
@@ -1582,6 +1602,7 @@ static void provider_initialize(struct vpn_provider *provider)
|
||||
provider->type = NULL;
|
||||
provider->domain = NULL;
|
||||
provider->identifier = NULL;
|
||||
+ provider->immutable = FALSE;
|
||||
provider->user_networks = NULL;
|
||||
provider->routes = g_hash_table_new_full(g_direct_hash, g_direct_equal,
|
||||
NULL, free_route);
|
||||
@@ -1995,8 +2016,7 @@ int __vpn_provider_create_from_config(GHashTable *settings,
|
||||
provider->config_file = g_strdup(config_ident);
|
||||
provider->config_entry = g_strdup(config_entry);
|
||||
|
||||
- if (provider_register(provider) == 0)
|
||||
- vpn_provider_load(provider);
|
||||
+ provider_register(provider);
|
||||
|
||||
provider_resolv_host_addr(provider);
|
||||
}
|
||||
@@ -2010,7 +2030,9 @@ 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);
|
||||
+
|
||||
+ provider->immutable = TRUE;
|
||||
|
||||
vpn_provider_save(provider);
|
||||
|
||||
@@ -2086,9 +2108,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) {
|
||||
@@ -2111,6 +2135,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;
|
||||
@@ -2118,6 +2149,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);
|
||||
|
||||
@@ -2131,13 +2165,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 c57fcf7..56e7a5c 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);
|
Loading…
x
Reference in New Issue
Block a user