diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-05-07 16:56:50 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-05-07 16:56:50 +0200 |
commit | 6ae9a6a1642fcaf808c934931139484776a56a9a (patch) | |
tree | cff7f7eb91f00d107bf2e9279df25f1ab52adb41 | |
parent | 385047779e8ae1a9be13a5dbaa7c6385b304fc4a (diff) | |
download | pam_network_manager-6ae9a6a1642fcaf808c934931139484776a56a9a.tar pam_network_manager-6ae9a6a1642fcaf808c934931139484776a56a9a.zip |
Fix race condition
-rw-r--r-- | pam_wlan.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -163,12 +163,16 @@ static NMDevice * find_device(NMClient *client) { return NULL; } -static void state_cb(NMActiveConnection *active_connection, GParamSpec *pspec, gpointer user_data) { +static void state_cb(NMDevice *device, GParamSpec *pspec, gpointer user_data) { cb_arg *arg = user_data; + NMActiveConnection *active_connection = nm_device_get_active_connection(device); + if (!active_connection) + return; + NMActiveConnectionState state = nm_active_connection_get_state(active_connection); - if (state != NM_ACTIVE_CONNECTION_STATE_ACTIVATING) { + if (state != NM_ACTIVE_CONNECTION_STATE_ACTIVATING && state != NM_ACTIVE_CONNECTION_STATE_DEACTIVATING) { if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) arg->ret = PAM_SUCCESS; @@ -182,8 +186,6 @@ static void activate_cb(NMClient *client, NMActiveConnection *active_connection, if (error) goto error; - g_signal_connect(active_connection, "notify::state", G_CALLBACK(state_cb), arg); - state_cb(active_connection, NULL, arg); return; @@ -201,6 +203,7 @@ static void add_cb(NMRemoteSettings *settings, NMRemoteConnection *con, GError * if (!device) goto error; + g_signal_connect(device, "notify::state", G_CALLBACK(state_cb), arg); nm_client_activate_connection(arg->client, NM_CONNECTION(con), device, NULL, activate_cb, arg); return; |