k_f 15/05/13 20:38:27
Added: pinentry-0.9.2-management.patch
pinentry-0.9.2-linking-order.patch
pinentry-0.9.2-handlers-return.patch
pinentry-0.9.2-cmd_confirm.patch
pinentry-0.9.2-memory.patch
pinentry-0.9.2-simplify.patch
pinentry-0.9.2-gnome3.patch
Log:
new upstream version 0.9.2 with fixes
(Portage version: 2.2.18/cvs/Linux x86_64, signed Manifest commit with key
0xFED5002857C1ABFA!)
Revision Changes Path
1.1 app-crypt/pinentry/files/pinentry-0.9.2-management.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/pinentry/files/pinentry-0.9.2-management.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/pinentry/files/pinentry-0.9.2-management.patch?rev=1.1&content-type=text/plain
Index: pinentry-0.9.2-management.patch
===================================================================
>From bdd81974633f8e31d582b62999ef9b004bc3b95e Mon Sep 17 00:00:00 2001
From: "Neal H. Walfield" <[email protected]>
Date: Wed, 13 May 2015 13:52:03 +0200
Subject: [PATCH 1/1] Make the management of pinentry.pin more explicit.
* pinentry/pinentry.c: Include <assert.h>.
(pinentry): Set pin_len to 0.
(pinentry_setbufferlen): If len is less than 2048, set it to 2048.
Add an assertion.
(pinentry_setbuffer_clear): New function that releases the pin buffer.
(pinentry_setbuffer_init): New function that initializes the pin
buffer.
(cmd_getpin): Use pinentry_setbuffer_init and pinentry_setbuffer_clear
instead of manual memory management.
(cmd_confirm): Use pinentry_setbuffer_clear instead of manual memory
management.
---
pinentry/pinentry.c | 52 +++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 39 insertions(+), 13 deletions(-)
diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index 3a44851..53216fc 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <assert.h>
#ifndef HAVE_W32CE_SYSTEM
# include <locale.h>
#endif
@@ -67,7 +68,7 @@ struct pinentry pinentry =
NULL, /* Not-Ok button. */
NULL, /* Cancel button. */
NULL, /* PIN. */
- 2048, /* PIN length. */
+ 0, /* PIN length. */
0, /* pin_from_cache. */
0, /* Display. */
0, /* TTY name. */
@@ -354,8 +355,18 @@ char *
pinentry_setbufferlen (pinentry_t pin, int len)
{
char *newp;
- if (len < pinentry.pin_len)
+
+ if (pin->pin_len)
+ assert (pin->pin);
+ else
+ assert (!pin->pin);
+
+ if (len < 2048)
+ len = 2048;
+
+ if (len <= pin->pin_len)
return NULL;
+
newp = secmem_realloc (pin->pin, len);
if (newp)
{
@@ -371,6 +382,28 @@ pinentry_setbufferlen (pinentry_t pin, int len)
return newp;
}
+static void
+pinentry_setbuffer_clear (pinentry_t pin)
+{
+ if (! pin->pin)
+ {
+ assert (pin->pin_len == 0);
+ return;
+ }
+
+ assert (pin->pin_len > 0);
+
+ secmem_free (pin->pin);
+ pin->pin = NULL;
+ pin->pin_len = 0;
+}
+
+static void
+pinentry_setbuffer_init (pinentry_t pin)
+{
+ pinentry_setbuffer_clear (pin);
+ pinentry_setbufferlen (pin, 0);
+}
/* Initialize the secure memory subsystem, drop privileges and return.
Must be called early. */
@@ -983,7 +1016,7 @@ cmd_getpin (ASSUAN_CONTEXT ctx, char *line)
int set_prompt = 0;
int just_read_password_from_cache = 0;
- pinentry.pin = secmem_malloc (pinentry.pin_len);
+ pinentry_setbuffer_init (&pinentry);
if (!pinentry.pin)
return ASSUAN_Out_Of_Core;
@@ -1065,11 +1098,7 @@ cmd_getpin (ASSUAN_CONTEXT ctx, char *line)
if (result < 0)
{
- if (pinentry.pin)
- {
- secmem_free (pinentry.pin);
- pinentry.pin = NULL;
- }
+ pinentry_setbuffer_clear (&pinentry);
if (pinentry.specific_err)
return pinentry.specific_err;
return pinentry.locale_err? ASSUAN_Locale_Problem: ASSUAN_Canceled;
@@ -1094,11 +1123,7 @@ cmd_getpin (ASSUAN_CONTEXT ctx, char *line)
password_cache_save (pinentry.keyinfo, pinentry.pin);
}
- if (pinentry.pin)
- {
- secmem_free (pinentry.pin);
- pinentry.pin = NULL;
- }
+ pinentry_setbuffer_clear (&pinentry);
return result;
}
@@ -1122,6 +1147,7 @@ cmd_confirm (ASSUAN_CONTEXT ctx, char *line)
pinentry.locale_err = 0;
pinentry.specific_err = 0;
pinentry.canceled = 0;
+ pinentry_setbuffer_clear (&pinentry);
result = (*pinentry_cmd_handler) (&pinentry);
if (pinentry.error)
{
--
2.1.4
1.1 app-crypt/pinentry/files/pinentry-0.9.2-linking-order.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/pinentry/files/pinentry-0.9.2-linking-order.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/pinentry/files/pinentry-0.9.2-linking-order.patch?rev=1.1&content-type=text/plain
Index: pinentry-0.9.2-linking-order.patch
===================================================================
>From 496235af8dfd373b54e5610f86bf1cada175ac23 Mon Sep 17 00:00:00 2001
From: "Neal H. Walfield" <[email protected]>
Date: Wed, 13 May 2015 21:47:11 +0200
Subject: [PATCH 1/1] Fix linking order to work when linked with --as-needed.
* curses/Makefile.am (LDADD): Add $(COMMON_LIBS) after all of the
local objects and object archives.
* gnome3/Makefile.am (LDADD): Likewise.
* gtk+-2/Makefile.am (LDADD): Likewise.
* qt4/Makefile.am (pinentry_qt4_LDADD): Likewise.
* tty/Makefile.am (LDADD): Likewise.
Reported-by: Daniel Kahn Gillmor <[email protected]>
---
curses/Makefile.am | 5 ++---
gnome3/Makefile.am | 5 ++---
gtk+-2/Makefile.am | 5 ++---
qt4/Makefile.am | 6 +++---
tty/Makefile.am | 4 ++--
5 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/curses/Makefile.am b/curses/Makefile.am
index e8ea031..4d764c7 100644
--- a/curses/Makefile.am
+++ b/curses/Makefile.am
@@ -22,9 +22,8 @@
bin_PROGRAMS = pinentry-curses
AM_CPPFLAGS = $(COMMON_CFLAGS) $(NCURSES_INCLUDE) -I$(top_srcdir)/pinentry
-LDADD = $(COMMON_LIBS) \
- ../pinentry/libpinentry.a ../pinentry/libpinentry-curses.a \
+LDADD = ../pinentry/libpinentry.a ../pinentry/libpinentry-curses.a \
../assuan/libassuan.a ../secmem/libsecmem.a \
- $(LIBCAP) $(LIBCURSES) $(LIBICONV)
+ $(COMMON_LIBS) $(LIBCAP) $(LIBCURSES) $(LIBICONV)
pinentry_curses_SOURCES = pinentry-curses.c
diff --git a/gnome3/Makefile.am b/gnome3/Makefile.am
index 78df706..46639de 100644
--- a/gnome3/Makefile.am
+++ b/gnome3/Makefile.am
@@ -32,8 +32,7 @@ endif
AM_CPPFLAGS = $(COMMON_CFLAGS) $(GNOME3CFLAGS) \
$(ncurses_include) -I$(top_srcdir)/assuan \
-I$(top_srcdir)/secmem -I$(top_srcdir)/pinentry
-LDADD = $(COMMON_LIBS) \
- ../pinentry/libpinentry.a ../assuan/libassuan.a ../secmem/libsecmem.a \
- $(LIBCAP) $(GNOME3LIBS) $(libcurses)
+LDADD = ../pinentry/libpinentry.a ../assuan/libassuan.a ../secmem/libsecmem.a \
+ $(COMMON_LIBS) $(LIBCAP) $(GNOME3LIBS) $(libcurses)
pinentry_gnome3_SOURCES = pinentry-gnome3.c
diff --git a/gtk+-2/Makefile.am b/gtk+-2/Makefile.am
index c98139f..7e37469 100644
--- a/gtk+-2/Makefile.am
+++ b/gtk+-2/Makefile.am
@@ -31,9 +31,8 @@ endif
AM_CPPFLAGS = $(COMMON_CFLAGS) $(GTK2CFLAGS) $(ncurses_include) \
-I$(top_srcdir)/secmem -I$(top_srcdir)/pinentry
-LDADD = $(COMMON_LIBS) \
- ../pinentry/libpinentry.a ../assuan/libassuan.a ../secmem/libsecmem.a \
- $(LIBCAP) $(GTK2LIBS) $(libcurses)
+LDADD = ../pinentry/libpinentry.a ../assuan/libassuan.a ../secmem/libsecmem.a \
+ $(COMMON_LIBS) $(LIBCAP) $(GTK2LIBS) $(libcurses)
pinentry_gtk_2_SOURCES = pinentry-gtk-2.c \
gtksecentry.c gtksecentry.h gseal-gtk-compat.h
diff --git a/qt4/Makefile.am b/qt4/Makefile.am
index 31274bb..816aade 100644
--- a/qt4/Makefile.am
+++ b/qt4/Makefile.am
@@ -38,10 +38,10 @@ AM_CPPFLAGS = $(COMMON_CFLAGS) \
-I$(top_srcdir) -I$(top_srcdir)/assuan -I$(top_srcdir)/secmem \
$(ncurses_include) -I$(top_srcdir)/pinentry
AM_CXXFLAGS = $(QT4_CORE_CFLAGS) $(QT4_GUI_CFLAGS)
-pinentry_qt4_LDADD = $(COMMON_LIBS) \
- $(QT4_CORE_LIBS) $(QT4_GUI_LIBS) $(libcurses) \
+pinentry_qt4_LDADD = \
../pinentry/libpinentry.a $(top_builddir)/assuan/libassuan.a \
- $(top_builddir)/secmem/libsecmem.a $(LIBCAP)
+ $(top_builddir)/secmem/libsecmem.a \
+ $(COMMON_LIBS) $(QT4_CORE_LIBS) $(QT4_GUI_LIBS) $(libcurses) $(LIBCAP)
BUILT_SOURCES = \
pinentryconfirm.moc qsecurelineedit.moc pinentrydialog.moc
diff --git a/tty/Makefile.am b/tty/Makefile.am
index 798c08f..aa805b2 100644
--- a/tty/Makefile.am
+++ b/tty/Makefile.am
@@ -21,8 +21,8 @@
bin_PROGRAMS = pinentry-tty
AM_CPPFLAGS = $(COMMON_CFLAGS) -I$(top_srcdir)/pinentry
-LDADD = $(COMMON_LIBS) ../pinentry/libpinentry.a \
+LDADD = ../pinentry/libpinentry.a \
../assuan/libassuan.a ../secmem/libsecmem.a \
- $(LIBCAP) $(LIBICONV)
+ $(COMMON_LIBS) $(LIBCAP) $(LIBICONV)
pinentry_tty_SOURCES = pinentry-tty.c
--
2.1.4
1.1
app-crypt/pinentry/files/pinentry-0.9.2-handlers-return.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/pinentry/files/pinentry-0.9.2-handlers-return.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/pinentry/files/pinentry-0.9.2-handlers-return.patch?rev=1.1&content-type=text/plain
Index: pinentry-0.9.2-handlers-return.patch
===================================================================
>From 3062742b945f95d72001896f8ba5468b9e63aa9b Mon Sep 17 00:00:00 2001
From: "Neal H. Walfield" <[email protected]>
Date: Wed, 13 May 2015 14:20:23 +0200
Subject: [PATCH 1/1] Don't interpret the handler's return value as the
passphrase's length.
* pinentry/pinentry.c (cmd_getpin): Don't interpret the return value
as the passphrase length. Use strlen instead.
---
pinentry/pinentry.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index 53216fc..836ee14 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -1109,7 +1109,7 @@ cmd_getpin (ASSUAN_CONTEXT ctx, char *line)
{
if (pinentry.repeat_okay)
assuan_write_status (ctx, "PIN_REPEATED", "");
- result = assuan_send_data (ctx, pinentry.pin, result);
+ result = assuan_send_data (ctx, pinentry.pin, strlen(pinentry.pin));
if (!result)
result = assuan_send_data (ctx, NULL, 0);
--
2.1.4
1.1 app-crypt/pinentry/files/pinentry-0.9.2-cmd_confirm.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/pinentry/files/pinentry-0.9.2-cmd_confirm.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/pinentry/files/pinentry-0.9.2-cmd_confirm.patch?rev=1.1&content-type=text/plain
Index: pinentry-0.9.2-cmd_confirm.patch
===================================================================
>From 29236f84aca64be72c97a9b5513457a4e45afbc6 Mon Sep 17 00:00:00 2001
From: "Neal H. Walfield" <[email protected]>
Date: Mon, 11 May 2015 16:14:58 +0200
Subject: [PATCH] Implement cmd_confirm in terms of cmd_message.
* pinentry/pinentry.c (cmd_confirm): Implement cmd_confirm in terms of
cmd_message.
---
pinentry/pinentry.c | 22 +---------------------
1 file changed, 1 insertion(+), 21 deletions(-)
diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index f28c576..11a8027 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -1146,27 +1146,7 @@ cmd_confirm (ASSUAN_CONTEXT ctx, char *line)
static int
cmd_message (ASSUAN_CONTEXT ctx, char *line)
{
- int result;
-
- pinentry.one_button = 1;
- pinentry.quality_bar = 0;
- pinentry.close_button = 0;
- pinentry.locale_err = 0;
- pinentry.specific_err = 0;
- result = (*pinentry_cmd_handler) (&pinentry);
- if (pinentry.error)
- {
- free (pinentry.error);
- pinentry.error = NULL;
- }
-
- if (pinentry.close_button)
- assuan_write_status (ctx, "BUTTON_INFO", "close");
-
- return result ? 0
- : (pinentry.specific_err? pinentry.specific_err :
- pinentry.locale_err? ASSUAN_Locale_Problem
- : 0);
+ return cmd_confirm (ctx, "--one-button");
}
/* GETINFO <what>
--
2.1.4
1.1 app-crypt/pinentry/files/pinentry-0.9.2-memory.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/pinentry/files/pinentry-0.9.2-memory.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/pinentry/files/pinentry-0.9.2-memory.patch?rev=1.1&content-type=text/plain
Index: pinentry-0.9.2-memory.patch
===================================================================
>From aa04dac66f2ee949e8789a3c91090b01646f2e57 Mon Sep 17 00:00:00 2001
From: "Neal H. Walfield" <[email protected]>
Date: Mon, 11 May 2015 16:14:18 +0200
Subject: [PATCH] Fix memory allocation in pinentry_setbufferlen.
* pinentry/pinentry.c (pinentry_setbufferlen): Set PIN->PIN to a
buffer that is LEN bytes large, not 2 * PIN->PIN_LENGTH.
---
pinentry/pinentry.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index 51c873c..f28c576 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -356,11 +356,11 @@ pinentry_setbufferlen (pinentry_t pin, int len)
char *newp;
if (len < pinentry.pin_len)
return NULL;
- newp = secmem_realloc (pin->pin, 2 * pin->pin_len);
+ newp = secmem_realloc (pin->pin, len);
if (newp)
{
pin->pin = newp;
- pin->pin_len *= 2;
+ pin->pin_len = len;
}
else
{
--
2.1.4
1.1 app-crypt/pinentry/files/pinentry-0.9.2-simplify.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/pinentry/files/pinentry-0.9.2-simplify.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/pinentry/files/pinentry-0.9.2-simplify.patch?rev=1.1&content-type=text/plain
Index: pinentry-0.9.2-simplify.patch
===================================================================
>From 831782b3b625ca81624fae0ee184da0d2fc46d96 Mon Sep 17 00:00:00 2001
From: "Neal H. Walfield" <[email protected]>
Date: Mon, 11 May 2015 16:35:12 +0200
Subject: [PATCH 1/1] Simplify code.
* pinentry/pinentry.c (cmd_confirm): Don't use nested ternary
expressions.
---
pinentry/pinentry.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index 11a8027..3a44851 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -1132,14 +1132,21 @@ cmd_confirm (ASSUAN_CONTEXT ctx, char *line)
if (pinentry.close_button)
assuan_write_status (ctx, "BUTTON_INFO", "close");
- return result ? 0
- : (pinentry.specific_err? pinentry.specific_err :
- pinentry.locale_err? ASSUAN_Locale_Problem
- : (pinentry.one_button
- ? 0
- : (pinentry.canceled
- ? ASSUAN_Canceled
- : ASSUAN_Not_Confirmed)));
+ if (result)
+ return 0;
+
+ if (pinentry.specific_err)
+ return pinentry.specific_err;
+
+ if (pinentry.locale_err)
+ return ASSUAN_Locale_Problem;
+
+ if (pinentry.one_button)
+ return 0;
+
+ if (pinentry.canceled)
+ return ASSUAN_Canceled;
+ return ASSUAN_Not_Confirmed;
}
--
2.1.4
1.1 app-crypt/pinentry/files/pinentry-0.9.2-gnome3.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/pinentry/files/pinentry-0.9.2-gnome3.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/pinentry/files/pinentry-0.9.2-gnome3.patch?rev=1.1&content-type=text/plain
Index: pinentry-0.9.2-gnome3.patch
===================================================================
>From be87785005d256b7f3dacc607ba5ea0a14de8593 Mon Sep 17 00:00:00 2001
From: "Neal H. Walfield" <[email protected]>
Date: Tue, 12 May 2015 17:07:49 +0200
Subject: [PATCH] Add a GNOME3 pinentry based on gcr.
* configure.ac (--enable-pinentry-gnome3): Option to enable the GNOME3
pinentry.
(pinentry_gnome_3): Set to yes if enabled and gcr-3 and gcr-base-3 gcr
is available.
(GNOME3CFLAGS): Define and AC_SUBST.
(GNOME3LIBS): Define and AC_SUBST.
(GCR_API_SUBJECT_TO_CHANGE): Define.
(BUILD_PINENTRY_GNOME_3): Define.
* Makefile.am (pinentry_gnome_3): Define.
(SUBDIRS): Add ${pinentry_gnome_3}.
* gnome3/Makefile.am: New file.
* gnome3/pinentry-gnome3.c: New file.
---
Makefile.am | 11 +-
configure.ac | 62 +++++++++--
gnome3/Makefile.am | 39 +++++++
gnome3/pinentry-gnome3.c | 271 +++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 370 insertions(+), 13 deletions(-)
create mode 100644 gnome3/Makefile.am
create mode 100644 gnome3/pinentry-gnome3.c
diff --git a/Makefile.am b/Makefile.am
index f8f7aac..177f37e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
# Makefile.am
-# Copyright (C) 2002, 2012 g10 Code GmbH
+# Copyright (C) 2002, 2012, 2015 g10 Code GmbH
#
# This file is part of PINENTRY.
#
@@ -46,6 +46,12 @@ else
pinentry_gtk_2 =
endif
+if BUILD_PINENTRY_GNOME_3
+pinentry_gnome_3 = gnome3
+else
+pinentry_gnome_3 =
+endif
+
if BUILD_PINENTRY_QT4
pinentry_qt4 = qt4
else
@@ -59,7 +65,8 @@ pinentry_w32 =
endif
SUBDIRS = assuan secmem pinentry ${pinentry_curses} ${pinentry_tty} \
- ${pinentry_gtk_2} ${pinentry_qt4} ${pinentry_w32} doc
+ ${pinentry_gtk_2} ${pinentry_gnome_3} ${pinentry_qt4} \
+ ${pinentry_w32} doc
install-exec-local:
diff --git a/configure.ac b/configure.ac
index c50ce68..9948d1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -274,28 +274,34 @@ fi
dnl
-dnl Check for GTK+-2 pinentry program.
+dnl Check for GTK+-2 / GNOME3 pinentry programs.
dnl
AC_ARG_ENABLE(pinentry-gtk2,
AC_HELP_STRING([--enable-pinentry-gtk2], [build GTK+-2 pinentry]),
pinentry_gtk_2=$enableval, pinentry_gtk_2=maybe)
+AC_ARG_ENABLE(pinentry-gnome3,
+ AC_HELP_STRING([--enable-pinentry-gnome3], [build GNOME 3
pinentry]),
+ pinentry_gnome_3=$enableval, pinentry_gnome_3=maybe)
+
dnl check for pkg-config
-if test "$pinentry_gtk_2" != "no"; then
+if test "$pinentry_gtk_2" != "no" -o "$pinentry_gnome_3" != "no"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test x"${PKG_CONFIG}" = xno ; then
pinentry_gtk_2=no
+ pinentry_gnome_3=no
fi
fi
dnl check if the module gtk+-2.0 exists
-if test "$pinentry_gtk_2" != "no"; then
+if test "$pinentry_gtk_2" != "no" -o "$pinentry_gnome_3" != "no"; then
AC_MSG_CHECKING([for gtk+-2])
"${PKG_CONFIG}" --exists gtk+-2.0
if test $? -ne 0 ; then
AC_MSG_RESULT([no])
AC_MSG_WARN([pkg-config could not find the module gtk+-2.0])
pinentry_gtk_2=no
+ pinentry_gnome_3=no
else
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([gtk+-2 version >= 2.4.0])
@@ -305,17 +311,45 @@ if test "$pinentry_gtk_2" != "no"; then
if test $? -ne 0 ; then
AC_MSG_WARN([building GTK+-2 pinentry disabled])
pinentry_gtk_2=no
+ pinentry_gnome_3=no
else
GTK2CFLAGS=`"${PKG_CONFIG}" --cflags gtk+-2.0`
GTK2LIBS=`"${PKG_CONFIG}" --libs gtk+-2.0`
AC_SUBST(GTK2CFLAGS)
AC_SUBST(GTK2LIBS)
- pinentry_gtk_2=yes
+ if test "$pinentry_gtk_2" != "no"
+ then
+ pinentry_gtk_2=yes
+ fi
+ if test "$pinentry_gnome_3" != "no"
+ then
+ pinentry_gnome_3=yes
+ fi
fi
fi
fi
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
+ if test $? -ne 0 ; then
+ AC_MSG_RESULT([no])
+ AC_MSG_WARN([pkg-config could not find the module
gcr-3,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`
+ AC_SUBST(GNOME3CFLAGS)
+ AC_SUBST(GNOME3LIBS)
+ AC_DEFINE(GCR_API_SUBJECT_TO_CHANGE, 1, [Nod nod])
+ pinentry_gnome_3=yes
+ fi
+fi
+
+AM_CONDITIONAL(BUILD_PINENTRY_GNOME_3, test "$pinentry_gnome_3" = "yes")
+
dnl
dnl Check for libsecret.
dnl
@@ -450,16 +484,20 @@ else
if test "$pinentry_qt4" = "yes"; then
PINENTRY_DEFAULT=pinentry-qt4
else
- if test "$pinentry_curses" = "yes"; then
- PINENTRY_DEFAULT=pinentry-curses
+ if test "$pinentry_gnome_3" = "yes"; then
+ PINENTRY_DEFAULT=pinentry-gnome3
else
- if test "$pinentry_tty" = "yes"; then
- PINENTRY_DEFAULT=pinentry-tty
+ if test "$pinentry_curses" = "yes"; then
+ PINENTRY_DEFAULT=pinentry-curses
else
- if test "$pinentry_w32" = "yes"; then
- PINENTRY_DEFAULT=pinentry-w32
+ if test "$pinentry_tty" = "yes"; then
+ PINENTRY_DEFAULT=pinentry-tty
else
- AC_MSG_ERROR([[No pinentry enabled.]])
+ if test "$pinentry_w32" = "yes"; then
+ PINENTRY_DEFAULT=pinentry-w32
+ else
+ AC_MSG_ERROR([[No pinentry enabled.]])
+ fi
fi
fi
fi
@@ -475,6 +513,7 @@ pinentry/Makefile
curses/Makefile
tty/Makefile
gtk+-2/Makefile
+gnome3/Makefile
qt4/Makefile
w32/Makefile
doc/Makefile
@@ -493,6 +532,7 @@ AC_MSG_NOTICE([
Curses Pinentry ..: $pinentry_curses
TTY Pinentry .....: $pinentry_tty
GTK+-2 Pinentry ..: $pinentry_gtk_2
+ GNOME 3 Pinentry .: $pinentry_gnome_3
Qt4 Pinentry .....: $pinentry_qt4 $pinentry_qt4_clip_msg
W32 Pinentry .....: $pinentry_w32
diff --git a/gnome3/Makefile.am b/gnome3/Makefile.am
new file mode 100644
index 0000000..78df706
--- /dev/null
+++ b/gnome3/Makefile.am
@@ -0,0 +1,39 @@
+# Makefile.am - PIN entry GTK+ frontend.
+# Copyright (C) 2002, 2015 g10 Code GmbH
+#
+# This file is part of PINENTRY.
+#
+# PINENTRY is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# PINENTRY is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+## Process this file with automake to produce Makefile.in
+
+bin_PROGRAMS = pinentry-gnome3
+
+if FALLBACK_CURSES
+ncurses_include = $(NCURSES_INCLUDE)
+libcurses = ../pinentry/libpinentry-curses.a $(LIBCURSES) $(LIBICONV)
+else
+ncurses_include =
+libcurses =
+endif
+
+AM_CPPFLAGS = $(COMMON_CFLAGS) $(GNOME3CFLAGS) \
+ $(ncurses_include) -I$(top_srcdir)/assuan \
+ -I$(top_srcdir)/secmem -I$(top_srcdir)/pinentry
+LDADD = $(COMMON_LIBS) \
+ ../pinentry/libpinentry.a ../assuan/libassuan.a ../secmem/libsecmem.a \
+ $(LIBCAP) $(GNOME3LIBS) $(libcurses)
+
+pinentry_gnome3_SOURCES = pinentry-gnome3.c
diff --git a/gnome3/pinentry-gnome3.c b/gnome3/pinentry-gnome3.c
new file mode 100644
index 0000000..74ec89c
--- /dev/null
+++ b/gnome3/pinentry-gnome3.c
@@ -0,0 +1,271 @@
+/* pinentry-gnome3.c
+ Copyright (C) 2015 g10 Code GmbH
+
+ pinentry-gnome-3 is a pinentry application for GNOME 3. It tries
+ to follow the Gnome Human Interface Guide as close as possible.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <gtk/gtk.h>
+#include <gcr/gcr-base.h>
+
+#include <string.h>
+
+#include "assuan.h"
+
+#include "memory.h"
+
+#include "pinentry.h"
+
+#ifdef FALLBACK_CURSES
+#include "pinentry-curses.h"
+#endif
+
+
+#define PGMNAME "pinentry-gnome3"
+
+#ifndef VERSION
+# define VERSION
+#endif
+
+static gchar *
+pinentry_utf8_validate (gchar *text)
+{
+ gchar *result;
+
+ if (!text)
+ return NULL;
+
+ if (g_utf8_validate (text, -1, NULL))
+ return g_strdup (text);
+
+ /* Failure: Assume that it was encoded in the current locale and
+ convert it to utf-8. */
+ result = g_locale_to_utf8 (text, -1, NULL, NULL, NULL);
+ if (!result)
+ {
+ gchar *p;
+
+ result = p = g_strdup (text);
+ while (!g_utf8_validate (p, -1, (const gchar **) &p))
+ *p = '?';
+ }
+ return result;
+}
+
+static GcrPrompt *
+create_prompt (pinentry_t pe, int confirm)
+{
+ GcrPrompt *prompt;
+ GError *error = NULL;
+ char *msg;
+
+ /* Create the prompt. */
+ prompt = GCR_PROMPT (gcr_system_prompt_open (-1, NULL, &error));
+ if (! prompt)
+ {
+ g_warning ("couldn't create prompt for gnupg passphrase: %s",
+ error->message);
+ g_error_free (error);
+ return NULL;
+ }
+
+ /* Set the messages for the various buttons, etc. */
+ if (pe->title)
+ {
+ msg = pinentry_utf8_validate (pe->title);
+ gcr_prompt_set_title (prompt, msg);
+ g_free (msg);
+ }
+
+ if (pe->description)
+ {
+ msg = pinentry_utf8_validate (pe->description);
+ gcr_prompt_set_description (prompt, msg);
+ g_free (msg);
+ }
+
+ /* An error occured during the last prompt. */
+ if (pe->error)
+ {
+ msg = pinentry_utf8_validate (pe->error);
+ gcr_prompt_set_warning (prompt, msg);
+ g_free (msg);
+ }
+
+ if (! pe->prompt && confirm)
+ gcr_prompt_set_message (prompt, "Message");
+ else if (! pe->prompt && ! confirm)
+ gcr_prompt_set_message (prompt, "Enter Passphrase");
+ else
+ {
+ msg = pinentry_utf8_validate (pe->prompt);
+ gcr_prompt_set_message (prompt, msg);
+ g_free (msg);
+ }
+
+ if (! confirm)
+ gcr_prompt_set_password_new (prompt, !!pe->repeat_passphrase);
+
+ if (pe->ok || pe->default_ok)
+ {
+ msg = pinentry_utf8_validate (pe->ok ?: pe->default_ok);
+ gcr_prompt_set_continue_label (prompt, msg);
+ g_free (msg);
+ }
+ /* XXX: Disable this button if pe->one_button is set. */
+ if (pe->cancel || pe->default_cancel)
+ {
+ msg = pinentry_utf8_validate (pe->cancel ?: pe->default_cancel);
+ gcr_prompt_set_cancel_label (prompt, msg);
+ g_free (msg);
+ }
+
+ if (confirm && pe->notok)
+ {
+ /* XXX: Add support for the third option. */
+ }
+
+ /* XXX: gcr expects a string; we have a int. */
+ // gcr_prompt_set_caller_window (prompt, pe->parent_wid);
+
+ if (! confirm && pe->allow_external_password_cache && pe->keyinfo)
+ {
+ if (pe->default_pwmngr)
+ {
+ msg = pinentry_utf8_validate (pe->default_pwmngr);
+ gcr_prompt_set_choice_label (prompt, msg);
+ g_free (msg);
+ }
+ else
+ gcr_prompt_set_choice_label
+ (prompt, "Automatically unlock this key, whenever I'm logged in");
+ }
+
+ return prompt;
+}
+
+static int
+gnome3_cmd_handler (pinentry_t pe)
+{
+ GcrPrompt *prompt = NULL;
+ GError *error = NULL;
+ int ret = -1;
+
+ if (pe->pin)
+ /* Passphrase mode. */
+ {
+ const char *password;
+
+ prompt = create_prompt (pe, 0);
+ if (! prompt)
+ /* Something went wrong. */
+ {
+ pe->canceled = 1;
+ return -1;
+ }
+
+ /* "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);
+ if (error)
+ /* Error. */
+ {
+ pe->specific_err = ASSUAN_General_Error;
+ g_error_free (error);
+ ret = -1;
+ }
+ else if (! password && ! error)
+ /* User cancelled the operation. */
+ ret = -1;
+ else
+ {
+ pinentry_setbufferlen (pe, strlen (password) + 1);
+ if (pe->pin)
+ strcpy (pe->pin, password);
+
+ if (pe->repeat_passphrase)
+ pe->repeat_okay = 1;
+
+ ret = 1;
+ }
+ }
+ else
+ /* Message box mode. */
+ {
+ GcrPromptReply reply;
+
+ prompt = create_prompt (pe, 1);
+ if (! prompt)
+ /* Something went wrong. */
+ {
+ pe->canceled = 1;
+ return -1;
+ }
+
+ /* XXX: We don't support a third button! */
+
+ reply = gcr_prompt_confirm_run (prompt, NULL, &error);
+ if (error)
+ {
+ pe->specific_err = ASSUAN_General_Error;
+ ret = 0;
+ }
+ else if (reply == GCR_PROMPT_REPLY_CONTINUE
+ /* XXX: Hack since gcr doesn't yet support one button
+ message boxes treat cancel the same as okay. */
+ || pe->one_button)
+ /* Confirmation. */
+ ret = 1;
+ else
+ /* GCR_PROMPT_REPLY_CANCEL */
+ {
+ pe->canceled = 1;
+ ret = 0;
+ }
+ }
+
+ if (prompt)
+ g_clear_object (&prompt);
+ return ret;
+}
+
+pinentry_cmd_handler_t pinentry_cmd_handler = gnome3_cmd_handler;
+
+int
+main (int argc, char *argv[])
+{
+ pinentry_init (PGMNAME);
+
+#ifdef FALLBACK_CURSES
+ if (pinentry_have_display (argc, argv))
+ gtk_init (&argc, &argv);
+ else
+ pinentry_cmd_handler = curses_cmd_handler;
+#else
+ gtk_init (&argc, &argv);
+#endif
+
+ pinentry_parse_opts (argc, argv);
+
+ if (pinentry_loop ())
+ return 1;
+
+ return 0;
+}
--
2.1.4