connman: update to connman-76e97ed (git)

This commit is contained in:
Stefan Saraev 2013-03-12 14:45:54 +02:00
parent bdf4bbccc2
commit c43e27d4ba
5 changed files with 3 additions and 570 deletions

View File

@ -19,13 +19,13 @@
################################################################################
PKG_NAME="connman"
PKG_VERSION="1.12"
PKG_VERSION="76e97ed"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="GPL"
PKG_SITE="http://www.connman.net"
PKG_URL="http://www.kernel.org/pub/linux/network/connman/$PKG_NAME-$PKG_VERSION.tar.xz"
#PKG_URL="$DISTRO_SRC/$PKG_NAME-$PKG_VERSION.tar.xz"
#PKG_URL="http://www.kernel.org/pub/linux/network/connman/$PKG_NAME-$PKG_VERSION.tar.xz"
PKG_URL="$DISTRO_SRC/$PKG_NAME-$PKG_VERSION.tar.xz"
PKG_DEPENDS="glib readline dbus systemd iptables wpa_supplicant ntp Python pygobject dbus-python"
PKG_BUILD_DEPENDS="toolchain glib readline dbus systemd iptables"
PKG_PRIORITY="optional"

View File

@ -1,20 +0,0 @@
diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index 0336636..40450eb 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -1869,9 +1869,14 @@ static const char *get_string(GHashTable *settings, const char *key)
static GSList *parse_user_networks(const char *network_str)
{
GSList *networks = NULL;
- char **elems = g_strsplit(network_str, ",", 0);
+ char **elems;
int i = 0;
+ if (network_str == NULL)
+ return NULL;
+
+ elems = g_strsplit(network_str, ",", 0);
+
if (elems == NULL)
return NULL;

View File

@ -1,66 +0,0 @@
diff --git a/vpn/vpn-manager.c b/vpn/vpn-manager.c
index 44684dd..1ba745b 100644
--- a/vpn/vpn-manager.c
+++ b/vpn/vpn-manager.c
@@ -85,8 +85,6 @@ static DBusMessage *get_connections(DBusConnection *conn, DBusMessage *msg,
if (reply == NULL)
return __connman_error_failed(msg, -EINVAL);
- __vpn_provider_check_connections();
-
return reply;
}
diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index 63a00ea..d885b46 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -1027,8 +1027,6 @@ static void configuration_count_del(void)
if (__sync_fetch_and_sub(&configuration_count, 1) != 1)
return;
-
- raise(SIGTERM);
}
int __vpn_provider_disconnect(struct vpn_provider *provider)
@@ -2507,28 +2505,6 @@ void vpn_provider_driver_unregister(struct vpn_provider_driver *driver)
}
}
-static gboolean check_vpn_count(gpointer data)
-{
- if (configuration_count == 0) {
- connman_info("No VPN configurations found, quitting.");
- raise(SIGTERM);
- }
-
- return FALSE;
-}
-
-void __vpn_provider_check_connections(void)
-{
- /*
- * If we were started when there is no providers configured,
- * then just quit. This happens when connman starts and its
- * vpn plugin asks connman-vpnd if it has any connections
- * configured. If there are none, then we can stop the vpn
- * daemon.
- */
- g_timeout_add(1000, check_vpn_count, NULL);
-}
-
const char *vpn_provider_get_name(struct vpn_provider *provider)
{
return provider->name;
diff --git a/vpn/vpn.h b/vpn/vpn.h
index 56e7a5c..53b117d 100644
--- a/vpn/vpn.h
+++ b/vpn/vpn.h
@@ -95,7 +95,6 @@ int __vpn_provider_connect_path(const char *path);
int __vpn_provider_disconnect(struct vpn_provider *provider);
int __vpn_provider_remove(const char *path);
int __vpn_provider_delete(struct vpn_provider *provider);
-void __vpn_provider_check_connections(void);
void __vpn_provider_cleanup(void);
int __vpn_provider_init(gboolean handle_routes);

View File

@ -1,270 +0,0 @@
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);

View File

@ -1,211 +0,0 @@
diff --git a/plugins/vpn.c b/plugins/vpn.c
index cbba396..f60a658 100644
--- a/plugins/vpn.c
+++ b/plugins/vpn.c
@@ -1438,6 +1438,8 @@ static void destroy_provider(struct connection_data *data)
if (data->call != NULL)
dbus_pending_call_cancel(data->call);
+ connman_provider_set_data(data->provider, NULL);
+
connman_provider_put(data->provider);
data->provider = NULL;
diff --git a/vpn/vpn-config.c b/vpn/vpn-config.c
index 1ece7e9..a1a2ed5 100644
--- a/vpn/vpn-config.c
+++ b/vpn/vpn-config.c
@@ -539,28 +539,40 @@ static void config_notify_handler(struct inotify_event *event,
}
if (event->mask & IN_CREATE)
- create_config(ident);
+ return;
+
+ if (event->mask & IN_DELETE) {
+ g_hash_table_remove(config_table, ident);
+ return;
+ }
if (event->mask & IN_MODIFY) {
struct vpn_config *config;
+ char *path = get_dir();
config = g_hash_table_lookup(config_table, ident);
if (config != NULL) {
- char *path = get_dir();
-
g_hash_table_remove_all(config->provider_table);
load_config(config, path, REMOVE);
/* Re-scan the config file for any changes */
g_hash_table_remove_all(config->provider_table);
load_config(config, path, ADD);
-
- g_free(path);
+ } else {
+ /*
+ * Inotify will send create event followed by modify
+ * event for any config file that is copied to
+ * monitored directory. So in practice we should just
+ * ignore the create event and trust only the modify
+ * one in order to avoid create/remove/create loop
+ */
+ config = create_config(ident);
+ if (config != NULL)
+ load_config(config, path, ADD);
}
- }
- if (event->mask & IN_DELETE)
- g_hash_table_remove(config_table, ident);
+ g_free(path);
+ }
}
int __vpn_config_init(void)
diff --git a/src/connman.h b/src/connman.h
index fc6d528..19bca74 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -559,7 +559,7 @@ int __connman_provider_indicate_state(struct connman_provider *provider,
int __connman_provider_indicate_error(struct connman_provider *provider,
enum connman_provider_error error);
int __connman_provider_connect(struct connman_provider *provider);
-int __connman_provider_remove(const char *path);
+int __connman_provider_remove_by_path(const char *path);
void __connman_provider_cleanup(void);
int __connman_provider_init(void);
diff --git a/src/manager.c b/src/manager.c
index 1d09267..e56f2e1 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -161,7 +161,7 @@ static DBusMessage *remove_provider(DBusConnection *conn,
dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
DBUS_TYPE_INVALID);
- err = __connman_provider_remove(path);
+ err = __connman_provider_remove_by_path(path);
if (err < 0)
return __connman_error_failed(msg, -err);
diff --git a/src/provider.c b/src/provider.c
index ca86880..b86e7d6 100644
--- a/src/provider.c
+++ b/src/provider.c
@@ -174,7 +174,7 @@ int __connman_provider_connect(struct connman_provider *provider)
return 0;
}
-int __connman_provider_remove(const char *path)
+int __connman_provider_remove_by_path(const char *path)
{
struct connman_provider *provider;
GHashTableIter iter;
diff --git a/include/provider.h b/include/provider.h
index bfefaed..fdd8ae0 100644
--- a/include/provider.h
+++ b/include/provider.h
@@ -79,6 +79,7 @@ void connman_provider_unref_debug(struct connman_provider *provider,
const char *file, int line, const char *caller);
int connman_provider_disconnect(struct connman_provider *provider);
+int connman_provider_remove(struct connman_provider *provider);
int connman_provider_set_string(struct connman_provider *provider,
const char *key, const char *value);
diff --git a/src/provider.c b/src/provider.c
index b86e7d6..f7bb4e1 100644
--- a/src/provider.c
+++ b/src/provider.c
@@ -150,6 +150,19 @@ int connman_provider_disconnect(struct connman_provider *provider)
return 0;
}
+int connman_provider_remove(struct connman_provider *provider)
+{
+ DBG("Removing VPN %s", provider->identifier);
+
+ provider_remove(provider);
+
+ connman_provider_set_state(provider, CONNMAN_PROVIDER_STATE_IDLE);
+
+ g_hash_table_remove(provider_hash, provider->identifier);
+
+ return 0;
+}
+
int __connman_provider_connect(struct connman_provider *provider)
{
int err;
diff --git a/plugins/vpn.c b/plugins/vpn.c
index f60a658..cda0c1b 100644
--- a/plugins/vpn.c
+++ b/plugins/vpn.c
@@ -1440,7 +1440,7 @@ static void destroy_provider(struct connection_data *data)
connman_provider_set_data(data->provider, NULL);
- connman_provider_put(data->provider);
+ connman_provider_remove(data->provider);
data->provider = NULL;
}
diff --git a/plugins/vpn.c b/plugins/vpn.c
index cda0c1b..f15796d 100644
--- a/plugins/vpn.c
+++ b/plugins/vpn.c
@@ -252,6 +252,8 @@ static void set_provider_state(struct connection_data *data)
enum connman_provider_state state = CONNMAN_PROVIDER_STATE_UNKNOWN;
int err = 0;
+ DBG("provider %p new state %s", data->provider, data->state);
+
if (g_str_equal(data->state, "ready") == TRUE) {
state = CONNMAN_PROVIDER_STATE_READY;
goto set;
diff --git a/plugins/vpn.c b/plugins/vpn.c
index f15796d..04318a9 100644
--- a/plugins/vpn.c
+++ b/plugins/vpn.c
@@ -796,6 +796,14 @@ static int provider_remove(struct connman_provider *provider)
DBG("provider %p data %p", provider, data);
+ if (data == NULL) {
+ /*
+ * This means the provider is already removed,
+ * just ignore the dbus in this case.
+ */
+ return -EALREADY;
+ }
+
/*
* When provider.c:provider_remove() calls this function,
* it will remove the provider itself after the call.
diff --git a/plugins/vpn.c b/plugins/vpn.c
index 04318a9..038a833 100644
--- a/plugins/vpn.c
+++ b/plugins/vpn.c
@@ -1508,6 +1508,7 @@ static gboolean connection_removed(DBusConnection *conn, DBusMessage *message,
{
const char *path;
const char *signature = DBUS_TYPE_OBJECT_PATH_AS_STRING;
+ struct connection_data *data;
if (dbus_message_has_signature(message, signature) == FALSE) {
connman_error("vpn removed signature \"%s\" does not match "
@@ -1518,7 +1519,11 @@ static gboolean connection_removed(DBusConnection *conn, DBusMessage *message,
dbus_message_get_args(message, NULL, DBUS_TYPE_OBJECT_PATH, &path,
DBUS_TYPE_INVALID);
- remove_connection(conn, path);
+
+ data = g_hash_table_lookup(vpn_connections, get_ident(path));
+ if (data != NULL)
+ remove_connection(conn, path);
+
return TRUE;
}