aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2009-07-13 18:46:06 +0200
committerGuido Günther <agx@sigxcpu.org>2009-07-13 18:46:06 +0200
commit7dfce86b3a06e5e5aa78e269df4d6c53b140024b (patch)
tree616beee41b26507b52fc6be319eb7c0ae6b3e3a5 /src
parentImported Upstream version 0.11 (diff)
downloadkrb5-auth-dialog-7dfce86b3a06e5e5aa78e269df4d6c53b140024b.tar.gz
krb5-auth-dialog-7dfce86b3a06e5e5aa78e269df4d6c53b140024b.tar.bz2
krb5-auth-dialog-7dfce86b3a06e5e5aa78e269df4d6c53b140024b.zip
Imported Upstream version 0.12
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in1
-rw-r--r--src/krb5-auth-applet.c1
-rw-r--r--src/krb5-auth-applet.h2
-rw-r--r--src/krb5-auth-dialog.c33
-rw-r--r--src/krb5-auth-pwdialog.c42
-rw-r--r--src/krb5-auth-pwdialog.h7
6 files changed, 52 insertions, 34 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index f3bb497..eb3720b 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -210,6 +210,7 @@ POSUB = @POSUB@
PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@
PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@
RANLIB = @RANLIB@
+SC_PKCS11 = @SC_PKCS11@
SED = @SED@
SETCAP = @SETCAP@
SET_MAKE = @SET_MAKE@
diff --git a/src/krb5-auth-applet.c b/src/krb5-auth-applet.c
index d59dac8..cc3f50e 100644
--- a/src/krb5-auth-applet.c
+++ b/src/krb5-auth-applet.c
@@ -613,6 +613,7 @@ ka_applet_cb_about_dialog (GtkMenuItem* menuitem G_GNUC_UNUSED,
"website-label", PACKAGE " website",
"website", "https://honk.sigxcpu.org/piki/projects/krb5-auth-dialog/",
"license", "GNU General Public License Version 2",
+ /* Translators: add the translators of your language here */
"translator-credits", _("translator-credits"),
NULL);
}
diff --git a/src/krb5-auth-applet.h b/src/krb5-auth-applet.h
index 35679bc..06e45f9 100644
--- a/src/krb5-auth-applet.h
+++ b/src/krb5-auth-applet.h
@@ -28,6 +28,8 @@
#include "config.h"
#include "krb5-auth-pwdialog.h"
+#define KA_NAME _("Network Authentication")
+
G_BEGIN_DECLS
#define KA_TYPE_APPLET (ka_applet_get_type ())
diff --git a/src/krb5-auth-dialog.c b/src/krb5-auth-dialog.c
index f163cd7..db3dcc5 100644
--- a/src/krb5-auth-dialog.c
+++ b/src/krb5-auth-dialog.c
@@ -50,8 +50,6 @@
# include <hx509_err.h>
#endif
-#define KA_NAME _("Network Authentication")
-
static krb5_context kcontext;
static krb5_principal kprincipal;
static krb5_timestamp creds_expiry;
@@ -137,7 +135,7 @@ get_principal_realm_data(krb5_principal p)
}
static const char*
-get_error_message(krb5_context context, krb5_error_code err)
+ka_get_error_message(krb5_context context, krb5_error_code err)
{
const char *msg = NULL;
@@ -368,7 +366,7 @@ credentials_expiring (gpointer *data)
retval = grab_credentials (applet);
give_up = canceled &&
(creds_expiry == canceled_creds_expiry);
- } while ((retval != 0) &&
+ } while ((retval != 0) &&
(retval != KRB5_REALM_CANT_RESOLVE) &&
(retval != KRB5_KDC_UNREACH) &&
invalid_auth &&
@@ -655,7 +653,7 @@ grab_credentials (KaApplet* applet)
break;
default:
KA_DEBUG("Auth failed with %d: %s", retval,
- get_error_message(kcontext, retval));
+ ka_get_error_message(kcontext, retval));
break;
}
goto out;
@@ -710,12 +708,12 @@ ka_renew_credentials (KaApplet* applet)
retval = krb5_cc_initialize(kcontext, ccache, kprincipal);
if(retval) {
- g_warning("krb5_cc_initialize: %s", get_error_message(kcontext, retval));
+ g_warning("krb5_cc_initialize: %s", ka_get_error_message(kcontext, retval));
goto out;
}
retval = krb5_cc_store_cred(kcontext, ccache, &my_creds);
if (retval) {
- g_warning("krb5_cc_store_cred: %s", get_error_message(kcontext, retval));
+ g_warning("krb5_cc_store_cred: %s", ka_get_error_message(kcontext, retval));
goto out;
}
}
@@ -807,23 +805,6 @@ ka_destroy_ccache (KaApplet *applet)
}
-static void
-ka_error_dialog(int err)
-{
- const char *msg = get_error_message(kcontext, err);
- GtkWidget *dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s", KA_NAME);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("Couldn't acquire kerberos ticket: '%s'"),
- _(msg));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-}
-
-
/*
* check if we have valid credentials for the requested principal - if not, grab them
* principal: requested principal - if empty use default
@@ -889,7 +870,9 @@ ka_grab_credentials (KaApplet* applet)
if (canceled)
break;
if (retval) {
- ka_error_dialog(retval);
+ ka_pwdialog_error(pwdialog,
+ ka_get_error_message(kcontext,
+ retval));
break;
} else {
success = TRUE;
diff --git a/src/krb5-auth-pwdialog.c b/src/krb5-auth-pwdialog.c
index dd0270a..0bfffd7 100644
--- a/src/krb5-auth-pwdialog.c
+++ b/src/krb5-auth-pwdialog.c
@@ -47,6 +47,7 @@ struct _KaPwDialogPrivate
GtkWidget* pw_entry; /* password entry field */
gboolean persist; /* don't hide the dialog when creds are still valid */
gboolean grabbed; /* keyboard grabbed? */
+ GtkWidget* error_dialog; /* error dialog */
};
@@ -121,9 +122,16 @@ window_state_changed (GtkWidget *win, GdkEventWindowState *event, gpointer data)
gint
-ka_pwdialog_run(KaPwDialog* pwdialog)
+ka_pwdialog_run(KaPwDialog* self)
{
- GtkWidget* dialog = pwdialog->priv->dialog;
+ GtkWidget *dialog = self->priv->dialog;
+
+ /* cleanup old error dialog, if present (e.g. user didn't acknowledge
+ * the error but clicked the tray icon again) */
+ if (self->priv->error_dialog) {
+ gtk_widget_destroy (self->priv->error_dialog);
+ self->priv->error_dialog = NULL;
+ }
/* make sure we pop up on top */
gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE);
@@ -132,15 +140,36 @@ ka_pwdialog_run(KaPwDialog* pwdialog)
* grab the keyboard so that people don't accidentally type their
* passwords in other windows.
*/
- g_signal_connect (dialog, "map-event", G_CALLBACK (grab_keyboard), pwdialog);
- g_signal_connect (dialog, "unmap-event", G_CALLBACK (ungrab_keyboard), pwdialog);
- g_signal_connect (dialog, "window-state-event", G_CALLBACK (window_state_changed), pwdialog);
+ g_signal_connect (dialog, "map-event", G_CALLBACK (grab_keyboard), self);
+ g_signal_connect (dialog, "unmap-event", G_CALLBACK (ungrab_keyboard), self);
+ g_signal_connect (dialog, "window-state-event", G_CALLBACK (window_state_changed), self);
- gtk_widget_grab_focus (pwdialog->priv->pw_entry);
+ gtk_widget_grab_focus (self->priv->pw_entry);
gtk_widget_show(dialog);
return gtk_dialog_run (GTK_DIALOG(dialog));
}
+
+void
+ka_pwdialog_error(KaPwDialog* self, const char *msg)
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (
+ GTK_WINDOW(self->priv->dialog),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "%s", KA_NAME);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _("Couldn't acquire kerberos ticket: '%s'"),
+ _(msg));
+ self->priv->error_dialog = dialog;
+ gtk_dialog_run (GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+}
+
+
void
ka_pwdialog_set_persist (KaPwDialog* pwdialog, gboolean persist)
{
@@ -247,6 +276,7 @@ ka_pwdialog_create(GtkBuilder* xml)
priv->status_label = GTK_WIDGET (gtk_builder_get_object (xml, "krb5_status_label"));
priv->krb_label = GTK_WIDGET (gtk_builder_get_object (xml, "krb5_message_label"));
priv->pw_entry = GTK_WIDGET (gtk_secure_entry_new ());
+ priv->error_dialog = NULL;
entry_hbox = GTK_WIDGET (gtk_builder_get_object (xml, "entry_hbox"));
gtk_container_add (GTK_CONTAINER (entry_hbox), priv->pw_entry);
diff --git a/src/krb5-auth-pwdialog.h b/src/krb5-auth-pwdialog.h
index 1e5c93d..a02d3fb 100644
--- a/src/krb5-auth-pwdialog.h
+++ b/src/krb5-auth-pwdialog.h
@@ -52,9 +52,10 @@ KaPwDialog* ka_pwdialog_create(GtkBuilder *xml);
/* setup everything for the next prompting */
void ka_pwdialog_setup (KaPwDialog* pwdialog, const gchar *krb5prompt,
gboolean invalid_auth);
-gint ka_pwdialog_run(KaPwDialog *applet);
-void ka_pwdialog_hide(const KaPwDialog *applet, gboolean force);
-void ka_pwdialog_set_persist(KaPwDialog *applet, gboolean persist);
+gint ka_pwdialog_run(KaPwDialog *pwdialog);
+void ka_pwdialog_hide(const KaPwDialog *pwdialog, gboolean force);
+void ka_pwdialog_set_persist(KaPwDialog *pwdialog, gboolean persist);
+void ka_pwdialog_error (KaPwDialog *pwdialog, const char *msg);
/* update the expiry information in the status entry */
gboolean ka_pwdialog_status_update (KaPwDialog *pwdialog);
const gchar* ka_pwdialog_get_password(KaPwDialog *dialog);
bgstack15