diff options
author | Martin Willi <martin@strongswan.org> | 2008-08-20 11:44:47 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2008-08-20 11:44:47 +0000 |
commit | 1b9f6c2410897a0cefe7efefd7b9b3140c3fc977 (patch) | |
tree | b88b837073d8b07e9d344e4ea318727c10223fbd /src | |
parent | 142eaea43c9feb4033c1e07151771f68da8630cc (diff) | |
download | strongswan-1b9f6c2410897a0cefe7efefd7b9b3140c3fc977.tar.bz2 strongswan-1b9f6c2410897a0cefe7efefd7b9b3140c3fc977.tar.xz |
handle DBUS permission problems gracefully
Diffstat (limited to 'src')
-rw-r--r-- | src/charon/plugins/nm/nm_plugin.c | 29 | ||||
-rw-r--r-- | src/charon/plugins/nm/nm_service.c | 7 |
2 files changed, 23 insertions, 13 deletions
diff --git a/src/charon/plugins/nm/nm_plugin.c b/src/charon/plugins/nm/nm_plugin.c index 353742346..f906dcaa2 100644 --- a/src/charon/plugins/nm/nm_plugin.c +++ b/src/charon/plugins/nm/nm_plugin.c @@ -35,6 +35,11 @@ struct private_nm_plugin_t { nm_plugin_t public; /** + * NetworkManager service (VPNPlugin) + */ + NMStrongswanPlugin *plugin; + + /** * Glib main loop for a thread, handles DBUS calls */ GMainLoop *loop; @@ -50,16 +55,9 @@ struct private_nm_plugin_t { */ static job_requeue_t run(private_nm_plugin_t *this) { - NMStrongswanPlugin *plugin; - GMainLoop *loop; - - plugin = nm_strongswan_plugin_new(this->creds); - - this->loop = loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(loop); - - g_main_loop_unref(loop); - g_object_unref(plugin); + this->loop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(this->loop); + g_main_loop_unref(this->loop); return JOB_REQUEUE_NONE; } @@ -73,6 +71,10 @@ static void destroy(private_nm_plugin_t *this) { g_main_loop_quit(this->loop); } + if (this->plugin) + { + g_object_unref(this->plugin); + } charon->credentials->remove_set(charon->credentials, &this->creds->set); this->creds->destroy(this->creds); free(this); @@ -96,6 +98,13 @@ plugin_t *plugin_create() this->creds = nm_creds_create(); charon->credentials->add_set(charon->credentials, &this->creds->set); + this->plugin = nm_strongswan_plugin_new(this->creds); + if (!this->plugin) + { + DBG1(DBG_CFG, "DBUS binding failed"); + destroy(this); + return NULL; + } charon->processor->queue_job(charon->processor, (job_t*)callback_job_create((callback_job_cb_t)run, this, NULL, NULL)); diff --git a/src/charon/plugins/nm/nm_service.c b/src/charon/plugins/nm/nm_service.c index 2fc4ab227..8e69c78e7 100644 --- a/src/charon/plugins/nm/nm_service.c +++ b/src/charon/plugins/nm/nm_service.c @@ -376,9 +376,10 @@ NMStrongswanPlugin *nm_strongswan_plugin_new(nm_creds_t *creds) NM_TYPE_STRONGSWAN_PLUGIN, NM_VPN_PLUGIN_DBUS_SERVICE_NAME, NM_DBUS_SERVICE_STRONGSWAN, NULL); - - NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin)->creds = creds; - + if (plugin) + { + NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin)->creds = creds; + } return plugin; } |