summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pam_network_manager_helper.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/pam_network_manager_helper.c b/pam_network_manager_helper.c
index 7043ade..1027591 100644
--- a/pam_network_manager_helper.c
+++ b/pam_network_manager_helper.c
@@ -123,6 +123,7 @@ typedef struct {
int ret;
GMainLoop *loop;
NMClient *client;
+ NMRemoteConnection *con;
} cb_arg;
@@ -140,6 +141,13 @@ static NMDevice * find_device(NMClient *client) {
return NULL;
}
+static gboolean timeout_cb(gpointer user_data) {
+ cb_arg *arg = user_data;
+ g_main_loop_quit(arg->loop);
+
+ return FALSE;
+}
+
static void state_cb(NMDevice *device, UNUSED GParamSpec *pspec, gpointer user_data) {
cb_arg *arg = user_data;
@@ -179,14 +187,24 @@ static void add_cb(UNUSED NMRemoteSettings *settings, NMRemoteConnection *con, G
if (!device)
goto error;
+ arg->con = con;
+
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);
+
+ g_timeout_add_seconds(CONNECTION_TIMEOUT, timeout_cb, arg);
return;
error:
g_main_loop_quit(arg->loop);
}
+static void delete_cb(UNUSED NMRemoteConnection *connection, UNUSED GError *error, gpointer user_data) {
+ cb_arg *arg = user_data;
+
+ g_main_loop_quit(arg->loop);
+}
+
static int authenticate(const char *user, const char *pass) {
DBusGConnection *dbus = NULL;
NMRemoteSettings *settings = NULL;
@@ -218,6 +236,16 @@ static int authenticate(const char *user, const char *pass) {
g_main_loop_run(arg.loop);
+ if (arg.ret == PAM_SUCCESS)
+ goto end;
+
+ /* Error */
+ if (arg.con) {
+ nm_remote_connection_delete(arg.con, delete_cb, &arg);
+
+ g_main_loop_run(arg.loop);
+ }
+
end:
g_object_unref(con);