[network-manager-openvpn/bg/secret-timeout-bgo767321] auth-dialog: notify user of request expiration
- From: Beniamino Galvani <bgalvani src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openvpn/bg/secret-timeout-bgo767321] auth-dialog: notify user of request expiration
- Date: Thu, 16 Jun 2016 18:56:13 +0000 (UTC)
commit 53ac29f96ae2a286d1dafff8e51f1652a3d0a3fb
Author: Beniamino Galvani <bgalvani redhat com>
Date: Thu Jun 16 17:07:53 2016 +0200
auth-dialog: notify user of request expiration
auth-dialog/main.c | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index df06d95..f12a2d4 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -27,6 +27,7 @@
#include <errno.h>
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
#include <gtk/gtk.h>
#include <libsecret/secret.h>
@@ -208,6 +209,23 @@ std_no_secrets_required (void)
{
printf ("%s\n%s\n\n\n", NM_OPENVPN_KEY_NOSECRET, "true");
}
+static gboolean
+stdin_ready_cb (GIOChannel *source, GIOCondition condition, gpointer user_data)
+{
+ NMAVpnPasswordDialog *dialog = user_data;
+ char *str;
+
+ if (!(condition & G_IO_IN))
+ return TRUE;
+
+ if (g_io_channel_read_line (source, &str, NULL, NULL, NULL) == G_IO_STATUS_NORMAL) {
+ if (g_str_has_prefix (str, "QUIT")) {
+ nma_vpn_password_dialog_set_expired (dialog, _("Timed out"));
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
static gboolean
std_ask_user (const char *vpn_name,
@@ -224,6 +242,8 @@ std_ask_user (const char *vpn_name,
{
NMAVpnPasswordDialog *dialog;
gboolean success = FALSE;
+ GIOChannel *channel;
+ guint channel_eventid;
g_return_val_if_fail (vpn_name != NULL, FALSE);
g_return_val_if_fail (prompt != NULL, FALSE);
@@ -233,6 +253,10 @@ std_ask_user (const char *vpn_name,
dialog = NMA_VPN_PASSWORD_DIALOG (nma_vpn_password_dialog_new (_("Authenticate VPN"), prompt, NULL));
+ channel = g_io_channel_unix_new (STDIN_FILENO);
+ channel_eventid = g_io_add_watch (channel, G_IO_IN, stdin_ready_cb, dialog);
+ g_io_channel_set_encoding (channel, NULL, NULL);
+
/* pre-fill dialog with existing passwords */
nma_vpn_password_dialog_set_show_password (dialog, need_password);
if (need_password)
@@ -263,6 +287,7 @@ std_ask_user (const char *vpn_name,
}
gtk_widget_destroy (GTK_WIDGET (dialog));
+ g_io_channel_unref (channel);
return success;
}
@@ -278,7 +303,7 @@ wait_for_quit (void)
start = time (NULL);
do {
errno = 0;
- n = read (0, &c, 1);
+ n = read (STDIN_FILENO, &c, 1);
if (n == 0 || (n < 0 && errno == EAGAIN))
g_usleep (G_USEC_PER_SEC / 10);
else if (n == 1) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]