handle DBUS permission problems gracefully
This commit is contained in:
@@ -34,6 +34,11 @@ struct private_nm_plugin_t {
|
||||
*/
|
||||
nm_plugin_t public;
|
||||
|
||||
/**
|
||||
* NetworkManager service (VPNPlugin)
|
||||
*/
|
||||
NMStrongswanPlugin *plugin;
|
||||
|
||||
/**
|
||||
* Glib main loop for a thread, handles DBUS calls
|
||||
*/
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user