[PINENTRY PATCH v2 1/2] gnome3: drop unnecessary use of gtk

Daniel Kahn Gillmor dkg at fifthhorseman.net
Fri Sep 9 10:43:45 CEST 2016


* configure.ac: pinentry-gnome3 only needs gcr-base, not gcr.
* gnome3/pinentry-gnome3.c (main): instead of testing whether GTK can
* be loaded, check for DBUS_SESSION_BUS_ADDRESS, (create_prompt): use
* fprintf (stderr, ...) instead of g_warning (...), to align with the
* rest of pinentry.c.

pinentry-gnome3 really just uses gcr and libsecret -- there is no
direct use of gtk at all.  By linking only to the minimal gcr-base-3
and avoiding gcr-3 itself, we remove many unnecessary library
dependencies from pinentry-gnome3.

Specifically, "ldd $(which pinentry-gnome3) | wc -l" goes from 69 to
23 on debian testing.

Signed-off-by: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
---
 configure.ac             |  8 ++++----
 gnome3/pinentry-gnome3.c | 16 ++++++----------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/configure.ac b/configure.ac
index 41e9d93..1620ebd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -476,15 +476,15 @@ AM_CONDITIONAL(BUILD_PINENTRY_GTK_2, test "$pinentry_gtk_2" = "yes")
 
 if test "$pinentry_gnome_3" != "no"; then
 	AC_MSG_CHECKING([for gcr])
-	"${PKG_CONFIG}" --exists gcr-3,gcr-base-3
+	"${PKG_CONFIG}" --exists gcr-base-3
 	if test $? -ne 0 ; then
 		AC_MSG_RESULT([no])
-		AC_MSG_WARN([pkg-config could not find the module gcr-3,gcr-base-3])
+		AC_MSG_WARN([pkg-config could not find the module gcr-base-3])
 		pinentry_gnome_3=no
 	else
 		AC_MSG_RESULT([yes])
-		GNOME3CFLAGS=`"${PKG_CONFIG}" --cflags gcr-3,gcr-base-3`
-		GNOME3LIBS=`"${PKG_CONFIG}" --libs gcr-3,gcr-base-3`
+		GNOME3CFLAGS=`"${PKG_CONFIG}" --cflags gcr-base-3`
+		GNOME3LIBS=`"${PKG_CONFIG}" --libs gcr-base-3`
 		AC_SUBST(GNOME3CFLAGS)
 		AC_SUBST(GNOME3LIBS)
 		AC_DEFINE(GCR_API_SUBJECT_TO_CHANGE, 1, [Nod nod])
diff --git a/gnome3/pinentry-gnome3.c b/gnome3/pinentry-gnome3.c
index 8f91cb8..95449da 100644
--- a/gnome3/pinentry-gnome3.c
+++ b/gnome3/pinentry-gnome3.c
@@ -22,10 +22,10 @@
 # include "config.h"
 #endif
 
-#include <gtk/gtk.h>
 #include <gcr/gcr-base.h>
 
 #include <string.h>
+#include <stdlib.h>
 
 #include <assuan.h>
 
@@ -80,7 +80,7 @@ create_prompt (pinentry_t pe, int confirm)
   prompt = GCR_PROMPT (gcr_system_prompt_open (-1, NULL, &error));
   if (! prompt)
     {
-      g_warning ("couldn't create prompt for gnupg passphrase: %s",
+      fprintf (stderr, "couldn't create prompt for gnupg passphrase: %s",
 		 error->message);
       g_error_free (error);
       return NULL;
@@ -185,7 +185,7 @@ gnome3_cmd_handler (pinentry_t pe)
 
       /* "The returned password is valid until the next time a method
 	 is called to display another prompt."  */
-      password = gcr_prompt_password_run (prompt, NULL, &error);
+      password = gcr_prompt_password (prompt, NULL, &error);
       if (error)
 	/* Error.  */
 	{
@@ -261,15 +261,11 @@ main (int argc, char *argv[])
   pinentry_init (PGMNAME);
 
 #ifdef FALLBACK_CURSES
-  if (pinentry_have_display (argc, argv))
+  if (!getenv ("DBUS_SESSION_BUS_ADDRESS"))
     {
-      if (! gtk_init_check (&argc, &argv))
-	pinentry_cmd_handler = curses_cmd_handler;
+      fprintf (stderr, "No $DBUS_SESSION_BUS_ADDRESS found, falling back to curses\n");
+      pinentry_cmd_handler = curses_cmd_handler;
     }
-  else
-    pinentry_cmd_handler = curses_cmd_handler;
-#else
-  gtk_init (&argc, &argv);
 #endif
 
   pinentry_parse_opts (argc, argv);
-- 
2.9.3




More information about the Gnupg-devel mailing list