aboutsummaryrefslogtreecommitdiff
path: root/src/ka-dialog.c
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-02-14 21:02:17 +0100
committerGuido Günther <agx@sigxcpu.org>2011-02-14 21:02:17 +0100
commit7b7e3193b5647606508a0342479f7b322ec31cc6 (patch)
treef79dd9b1cfa2cf7a439be149ccbe1dac78867d37 /src/ka-dialog.c
parentDocument changes and release 0.17-1 (diff)
parentNew upstream version 2.91.6 (diff)
downloadkrb5-auth-dialog-7b7e3193b5647606508a0342479f7b322ec31cc6.tar.gz
krb5-auth-dialog-7b7e3193b5647606508a0342479f7b322ec31cc6.tar.bz2
krb5-auth-dialog-7b7e3193b5647606508a0342479f7b322ec31cc6.zip
Merge commit 'upstream/2.91.6'
Diffstat (limited to 'src/ka-dialog.c')
-rw-r--r--src/ka-dialog.c121
1 files changed, 50 insertions, 71 deletions
diff --git a/src/ka-dialog.c b/src/ka-dialog.c
index f11293d..ce86367 100644
--- a/src/ka-dialog.c
+++ b/src/ka-dialog.c
@@ -32,7 +32,6 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
-#include "gtksecentry.h"
#include "secmem-util.h"
#include "memory.h"
@@ -44,7 +43,7 @@
#include "ka-tickets.h"
#ifdef ENABLE_NETWORK_MANAGER
-#include <libnm_glib.h>
+#include <nm-client.h>
#endif
#ifdef HAVE_HX509_ERR_H
@@ -65,7 +64,7 @@ static int ka_renew_credentials (KaApplet* applet);
static gboolean ka_get_tgt_from_ccache (krb5_context context, krb5_creds *creds);
#ifdef ENABLE_NETWORK_MANAGER
-libnm_glib_ctx *nm_context;
+NMClient *nm_client;
#endif
/* YAY for different Kerberos implementations */
@@ -403,6 +402,9 @@ auth_dialog_prompter (krb5_context ctx G_GNUC_UNUSED,
canceled = FALSE;
canceled_creds_expiry = 0;
+ if (banner && !num_prompts)
+ ka_applet_set_msg (applet, banner);
+
for (i = 0; i < num_prompts; i++) {
const gchar *password = NULL;
int password_len = 0;
@@ -454,29 +456,30 @@ cleanup:
#ifdef ENABLE_NETWORK_MANAGER
static void
-network_state_cb (libnm_glib_ctx *context,
- gpointer data)
+ka_nm_client_state_changed_cb (NMClient *client,
+ GParamSpec *pspec G_GNUC_UNUSED,
+ gpointer data)
{
- gboolean *online = (gboolean*) data;
-
- libnm_glib_state state;
-
- state = libnm_glib_get_network_state (context);
-
- switch (state)
- {
- case LIBNM_NO_DBUS:
- case LIBNM_NO_NETWORKMANAGER:
- case LIBNM_INVALID_CONTEXT:
- /* do nothing */
- break;
- case LIBNM_NO_NETWORK_CONNECTION:
- *online = FALSE;
- break;
- case LIBNM_ACTIVE_NETWORK_CONNECTION:
- *online = TRUE;
- break;
- }
+ NMState state;
+ gboolean *online = (gboolean*) data;
+
+ state = nm_client_get_state(client);
+ switch (state) {
+ case NM_STATE_UNKNOWN:
+ case NM_STATE_ASLEEP:
+ case NM_STATE_CONNECTING:
+ KA_DEBUG("Network state: %d", state);
+ /* do nothing */
+ break;
+ case NM_STATE_DISCONNECTED:
+ KA_DEBUG("Network disconnected");
+ *online = FALSE;
+ break;
+ case NM_STATE_CONNECTED:
+ KA_DEBUG("Network connected");
+ *online = TRUE;
+ break;
+ }
}
#endif
@@ -484,38 +487,17 @@ network_state_cb (libnm_glib_ctx *context,
static gboolean
credentials_expiring (gpointer *data)
{
- int retval;
- gboolean give_up;
KaApplet* applet = KA_APPLET(data);
KA_DEBUG("Checking expiry <%ds", ka_applet_get_pw_prompt_secs(applet));
if (credentials_expiring_real (applet) && is_online) {
KA_DEBUG("Expiry @ %ld", creds_expiry);
- if (!ka_renew_credentials (applet)) {
+ if (!ka_renew_credentials (applet))
KA_DEBUG("Credentials renewed");
- goto out;
- }
-
- /* no popup when using a trayicon */
- if (ka_applet_get_show_trayicon(applet))
- goto out;
-
- give_up = canceled && (creds_expiry == canceled_creds_expiry);
- if (!give_up) {
- do {
- retval = grab_credentials (applet);
- give_up = canceled &&
- (creds_expiry == canceled_creds_expiry);
- } while ((retval != 0) &&
- (retval != KRB5_REALM_CANT_RESOLVE) &&
- (retval != KRB5_KDC_UNREACH) &&
- invalid_auth &&
- !give_up);
- }
}
-out:
ka_applet_update_status(applet, creds_expiry);
+
return TRUE;
}
@@ -845,7 +827,8 @@ ka_renew_credentials (KaApplet* applet)
my_creds.times.endtime);
}
out:
- creds_expiry = my_creds.times.endtime;
+ if (!retval)
+ creds_expiry = my_creds.times.endtime;
krb5_free_cred_contents (kcontext, &my_creds);
krb5_cc_close (kcontext, ccache);
return retval;
@@ -1033,10 +1016,10 @@ static void
ka_nm_shutdown(void)
{
#ifdef ENABLE_NETWORK_MANAGER
- if (nm_context) {
- libnm_glib_shutdown (nm_context);
- nm_context = NULL;
- }
+ if (nm_client) {
+ g_object_unref (nm_client);
+ nm_client = NULL;
+ }
#endif
}
@@ -1045,21 +1028,18 @@ static gboolean
ka_nm_init(void)
{
#ifdef ENABLE_NETWORK_MANAGER
- guint32 nm_callback_id;
-
- nm_context = libnm_glib_init ();
- if (!nm_context) {
- g_warning ("Could not initialize libnm_glib");
- } else {
- nm_callback_id = libnm_glib_register_callback (nm_context, network_state_cb, &is_online, NULL);
- if (nm_callback_id == 0) {
- ka_nm_shutdown ();
-
- g_warning ("Could not connect to NetworkManager, connection status will not be managed!");
- }
- }
+ nm_client = nm_client_new();
+ if (!nm_client) {
+ g_warning ("Could not initialize nm-client");
+ } else {
+ g_signal_connect(nm_client, "notify::state",
+ G_CALLBACK(ka_nm_client_state_changed_cb),
+ &is_online);
+ /* Set initial state */
+ ka_nm_client_state_changed_cb(nm_client, NULL, &is_online);
+ }
#endif /* ENABLE_NETWORK_MANAGER */
- return TRUE;
+ return TRUE;
}
@@ -1117,10 +1097,9 @@ main (int argc, char *argv[])
return 1;
ka_nm_init();
- if (credentials_expiring ((gpointer)applet)) {
- g_timeout_add_seconds (CREDENTIAL_CHECK_INTERVAL, (GSourceFunc)credentials_expiring, applet);
- monitor = monitor_ccache (applet);
- }
+ g_timeout_add_seconds (CREDENTIAL_CHECK_INTERVAL, (GSourceFunc)credentials_expiring, applet);
+ monitor = monitor_ccache (applet);
+
ka_dbus_service(applet);
gtk_main ();
}
bgstack15