[git] Pinentry - branch, master, updated. pinentry-0.9.7-49-ge353f4d
by Daniel Kahn Gillmor
cvs at cvs.gnupg.org
Mon Nov 7 01:06:32 CET 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The standard pinentry collection".
The branch, master has been updated
via e353f4d1ac31e58f46eeba29279adf809dfb96a9 (commit)
from 2e17565fd9cb94afe840050780d28db75e5c4053 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e353f4d1ac31e58f46eeba29279adf809dfb96a9
Author: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
Date: Sun Nov 6 02:17:04 2016 -0500
gnome3: Fall back to curses if screensaver is locked.
* gnome3/pinentry-gnome3.c (pe_gnome_screen_locked): New Function.
Returns true only if we can talk to a GNOME screensaver over D-Bus and
it assures us that it is locked.
(main): If GNOME screensaver is locked, fall back to curses.
--
We assume that if pinentry is triggered while the screensaver is
locked, then it is likely being done by some sort of remote connection
(e.g. ssh), and isn't being done directly from the graphical console.
In that case, prompting at the graphical console won't be able to get
the attention of the user, so we should fall back to curses if
possible.
GnuPG-bug-id: 2818
diff --git a/gnome3/pinentry-gnome3.c b/gnome3/pinentry-gnome3.c
index ba6ab46..e06885e 100644
--- a/gnome3/pinentry-gnome3.c
+++ b/gnome3/pinentry-gnome3.c
@@ -390,6 +390,71 @@ pe_gcr_timeout_done (gpointer user_data)
pinentry_cmd_handler_t pinentry_cmd_handler = gnome3_cmd_handler;
+/* Test whether there is a GNOME screensaver running that happens to
+ * be locked. Note that if there is no GNOME screensaver running at
+ * all the answer is still FALSE. */
+static gboolean
+pe_gnome_screen_locked (void)
+{
+ GDBusConnection *dbus;
+ GError *error = NULL;
+ GVariant *reply, *reply_bool;
+ gboolean ret;
+
+ dbus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+
+ if (!dbus)
+ {
+ fprintf (stderr, "failed to connect to user session D-Bus (%d): %s",
+ error ? error->code : -1,
+ error ? error->message : "<no GError>");
+ if (error)
+ g_error_free (error);
+ return FALSE;
+ }
+
+ /* this is intended to be the equivalent of:
+ * dbus-send --print-reply=literal --session \
+ * --dest=org.gnome.ScreenSaver \
+ * /org/gnome/ScreenSaver \
+ * org.gnome.ScreenSaver.GetActive
+ */
+ reply = g_dbus_connection_call_sync (dbus,
+ "org.gnome.ScreenSaver",
+ "/org/gnome/ScreenSaver",
+ "org.gnome.ScreenSaver",
+ "GetActive",
+ NULL,
+ ((const GVariantType *) "(b)"),
+ G_DBUS_CALL_FLAGS_NO_AUTO_START,
+ 0,
+ NULL,
+ &error);
+ g_object_unref(dbus);
+ if (!reply)
+ {
+ fprintf (stderr, "failed to get reply (%d): %s",
+ error ? error->code : -1,
+ error ? error->message : "<no GError>");
+ if (error)
+ g_error_free (error);
+ return FALSE;
+ }
+ reply_bool = g_variant_get_child_value (reply, 0);
+ if (!reply_bool)
+ {
+ fprintf (stderr, "failed to get boolean from reply\n");
+ ret = FALSE;
+ }
+ else
+ {
+ ret = g_variant_get_boolean (reply_bool);
+ g_variant_unref (reply_bool);
+ }
+
+ g_variant_unref (reply);
+ return ret;
+}
/* Test whether we can create a system prompt or not. This briefly
* does create a system prompt, which blocks other tools from making
@@ -443,6 +508,12 @@ main (int argc, char *argv[])
" falling back to curses\n");
pinentry_cmd_handler = curses_cmd_handler;
}
+ else if (pe_gnome_screen_locked ())
+ {
+ fprintf (stderr, "GNOME screensaver is locked,"
+ " falling back to curses\n");
+ pinentry_cmd_handler = curses_cmd_handler;
+ }
#endif
pinentry_parse_opts (argc, argv);
-----------------------------------------------------------------------
Summary of changes:
gnome3/pinentry-gnome3.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
hooks/post-receive
--
The standard pinentry collection
http://git.gnupg.org
More information about the Gnupg-commits
mailing list