[PINENTRY PATCH] gnome3: drop unnecessary use of gtk

Daniel Kahn Gillmor dkg at fifthhorseman.net
Tue Aug 30 01:55:48 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

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 | 12 ++++--------
 2 files changed, 8 insertions(+), 12 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..adf1062 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>
 
@@ -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