[gdm/multi-stack: 23/45] Notify plugins if their user choose requests fail
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/multi-stack: 23/45] Notify plugins if their user choose requests fail
- Date: Tue, 27 Apr 2010 19:42:58 +0000 (UTC)
commit 114b9be6024ef4b6c73fb7c1ad909346b6379d91
Author: Ray Strode <rstrode redhat com>
Date: Mon Mar 2 17:09:16 2009 -0500
Notify plugins if their user choose requests fail
This allows the smart card plugin to cancel pending
conversations when a card gets inserted.
This isn't perfect. We really want to only cancel
the conversations if they're for a user other
than the user the smartcard is for.
common/gdm-marshal.list | 1 +
gui/simple-greeter/gdm-greeter-login-window.c | 12 ++++++++-
gui/simple-greeter/libgdmsimplegreeter/Makefile.am | 2 +
.../libgdmsimplegreeter/gdm-conversation.c | 19 +++++++++++-----
.../libgdmsimplegreeter/gdm-conversation.h | 6 ++--
.../plugins/smartcard/gdm-smartcard-extension.c | 23 +++++++++++++++----
6 files changed, 47 insertions(+), 16 deletions(-)
---
diff --git a/common/gdm-marshal.list b/common/gdm-marshal.list
index d5455e1..d8a9e72 100644
--- a/common/gdm-marshal.list
+++ b/common/gdm-marshal.list
@@ -5,3 +5,4 @@ VOID:STRING,STRING
VOID:UINT,UINT
VOID:STRING,INT
VOID:DOUBLE
+BOOLEAN:STRING
diff --git a/gui/simple-greeter/gdm-greeter-login-window.c b/gui/simple-greeter/gdm-greeter-login-window.c
index 0c06607..8bbd07e 100644
--- a/gui/simple-greeter/gdm-greeter-login-window.c
+++ b/gui/simple-greeter/gdm-greeter-login-window.c
@@ -1972,7 +1972,7 @@ on_conversation_cancel (GdmGreeterLoginWindow *login_window,
do_cancel (login_window);
}
-static void
+static gboolean
on_conversation_chose_user (GdmGreeterLoginWindow *login_window,
const char *username,
GdmConversation *conversation)
@@ -1983,7 +1983,13 @@ on_conversation_chose_user (GdmGreeterLoginWindow *login_window,
name = gdm_task_get_name (GDM_TASK (conversation));
g_warning ("Task %s is trying to choose user before list is loaded", name);
g_free (name);
- return;
+ return FALSE;
+ }
+
+ /* If we're already authenticating then we can't pick a user
+ */
+ if (login_window->priv->dialog_mode == MODE_AUTHENTICATION) {
+ return FALSE;
}
if (gdm_task_list_set_active_task (GDM_TASK_LIST (login_window->priv->conversation_list),
@@ -1991,6 +1997,8 @@ on_conversation_chose_user (GdmGreeterLoginWindow *login_window,
gdm_user_chooser_widget_set_chosen_user_name (GDM_USER_CHOOSER_WIDGET (login_window->priv->user_chooser),
username);
}
+
+ return TRUE;
}
void
diff --git a/gui/simple-greeter/libgdmsimplegreeter/Makefile.am b/gui/simple-greeter/libgdmsimplegreeter/Makefile.am
index 1ef5725..0d7a0bd 100644
--- a/gui/simple-greeter/libgdmsimplegreeter/Makefile.am
+++ b/gui/simple-greeter/libgdmsimplegreeter/Makefile.am
@@ -3,6 +3,7 @@ NULL =
AM_CPPFLAGS = \
-I. \
-I.. \
+ -I$(top_srcdir)/common \
-DBINDIR=\"$(bindir)\" \
-DDATADIR=\"$(datadir)\" \
-DLIBDIR=\"$(libdir)\" \
@@ -28,6 +29,7 @@ libgdmsimplegreeter_la_SOURCES = \
libgdmsimplegreeter_la_LIBADD = \
$(GTK_LIBS) \
+ $(top_builddir)/common/libgdmcommon.la \
$(NULL)
libgdmsimplegreeter_la_LDFLAGS = \
diff --git a/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.c b/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.c
index cef435c..ee763ef 100644
--- a/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.c
+++ b/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.c
@@ -25,9 +25,9 @@
#include <gtk/gtk.h>
#include "gdm-conversation.h"
+#include "gdm-marshal.h"
#include "gdm-task.h"
-
enum {
ANSWER,
USER_CHOSEN,
@@ -76,12 +76,12 @@ gdm_conversation_class_init (gpointer g_iface)
signals [USER_CHOSEN] =
g_signal_new ("user-chosen",
iface_type,
- G_SIGNAL_RUN_FIRST,
+ G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdmConversationIface, user_chosen),
NULL,
NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
+ gdm_marshal_BOOLEAN__STRING,
+ G_TYPE_BOOLEAN,
1, G_TYPE_STRING);
signals [CANCEL] =
g_signal_new ("cancel",
@@ -171,9 +171,16 @@ gdm_conversation_cancel (GdmConversation *conversation)
{
g_signal_emit (conversation, signals [CANCEL], 0);
}
-void
+
+gboolean
gdm_conversation_choose_user (GdmConversation *conversation,
const char *username)
{
- g_signal_emit (conversation, signals [USER_CHOSEN], 0, username);
+ gboolean was_chosen;
+
+ was_chosen = FALSE;
+
+ g_signal_emit (conversation, signals [USER_CHOSEN], 0, username, &was_chosen);
+
+ return was_chosen;
}
diff --git a/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.h b/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.h
index fb4bf49..b37b21e 100644
--- a/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.h
+++ b/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.h
@@ -61,7 +61,7 @@ struct _GdmConversationIface
/* signals */
char * (* answer) (GdmConversation *conversation);
void (* cancel) (GdmConversation *conversation);
- void (* user_chosen) (GdmConversation *conversation);
+ gboolean (* user_chosen) (GdmConversation *conversation);
};
GType gdm_conversation_get_type (void) G_GNUC_CONST;
@@ -85,8 +85,8 @@ gboolean gdm_conversation_focus (GdmConversation *conversation);
void gdm_conversation_answer (GdmConversation *conversation,
const char *answer);
void gdm_conversation_cancel (GdmConversation *conversation);
-void gdm_conversation_choose_user (GdmConversation *conversation,
- const char *username);
+gboolean gdm_conversation_choose_user (GdmConversation *conversation,
+ const char *username);
G_END_DECLS
diff --git a/gui/simple-greeter/plugins/smartcard/gdm-smartcard-extension.c b/gui/simple-greeter/plugins/smartcard/gdm-smartcard-extension.c
index a9e41f4..274132e 100644
--- a/gui/simple-greeter/plugins/smartcard/gdm-smartcard-extension.c
+++ b/gui/simple-greeter/plugins/smartcard/gdm-smartcard-extension.c
@@ -53,6 +53,7 @@ struct _GdmSmartcardExtensionPrivate
int number_of_tokens;
guint answer_pending : 1;
+ guint select_when_ready : 1;
};
static void gdm_smartcard_extension_finalize (GObject *object);
@@ -102,8 +103,14 @@ on_smartcard_event (GIOChannel *io_channel,
}
if (extension->priv->number_of_tokens == 1) {
- gdm_conversation_choose_user (GDM_CONVERSATION (extension),
- PAMSERVICENAME);
+ if (!gdm_conversation_choose_user (GDM_CONVERSATION (extension),
+ PAMSERVICENAME)) {
+ g_debug ("could not choose smart card user, cancelling...");
+ gdm_conversation_cancel (GDM_CONVERSATION (extension));
+ extension->priv->select_when_ready = TRUE;
+ } else {
+ g_debug ("chose smart card user!");
+ }
} else if (extension->priv->number_of_tokens == 0) {
gdm_conversation_cancel (GDM_CONVERSATION (extension));
}
@@ -210,10 +217,16 @@ gdm_smartcard_extension_set_ready (GdmConversation *conversation)
GdmSmartcardExtension *extension = GDM_SMARTCARD_EXTENSION (conversation);
gdm_task_set_enabled (GDM_TASK (conversation), TRUE);
- if (extension->priv->worker_pid <= 0)
- {
+ if (extension->priv->worker_pid <= 0) {
watch_for_smartcards (extension);
- }
+ }
+
+ if (extension->priv->select_when_ready) {
+ if (gdm_conversation_choose_user (GDM_CONVERSATION (extension),
+ PAMSERVICENAME)) {
+ extension->priv->select_when_ready = FALSE;
+ }
+ }
}
char *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]