commit:     e5746ec14d4a8dd7990f76d1cf2779d32108bb9f
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 27 21:48:04 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Feb 27 21:51:16 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e5746ec1

app-crypt/pinentry: backport include fix

Revbump given both:
a) implicit function declarations;
b) Werner's comment on the upstream bug wrt possibility of it breaking
some things with other pinentries.

Closes: https://bugs.gentoo.org/925557
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/pinentry-1.2.1-include-memory.patch      | 313 +++++++++++++++++++++
 app-crypt/pinentry/pinentry-1.2.1-r6.ebuild        | 108 +++++++
 2 files changed, 421 insertions(+)

diff --git a/app-crypt/pinentry/files/pinentry-1.2.1-include-memory.patch 
b/app-crypt/pinentry/files/pinentry-1.2.1-include-memory.patch
new file mode 100644
index 000000000000..8c67950af6f3
--- /dev/null
+++ b/app-crypt/pinentry/files/pinentry-1.2.1-include-memory.patch
@@ -0,0 +1,313 @@
+https://bugs.gentoo.org/925557
+https://dev.gnupg.org/D566
+
+From 8ab1682e80a2b4185ee9ef66cbb44340245966fc Mon Sep 17 00:00:00 2001
+From: Werner Koch <[email protected]>
+Date: Mon, 20 Mar 2023 08:31:04 +0100
+Subject: [PATCH] Fix problem with inclusion of wrong memory.h.
+
+* secmem/memory.h: Rename to ...
+* secmem/secmem.h: this.
+* pinentry/pinentry.h: Include secmem.h.  Remove almost all inclusions
+of memory.h or replace them by "../secmem/secmem.h".
+--
+
+See-also: https://dev.gnupg.org/D566
+---
+ fltk/main.cxx                 | 1 -
+ fltk/pinwindow.cxx            | 2 +-
+ gnome3/pinentry-gnome3.c      | 2 --
+ pinentry/password-cache.c     | 2 +-
+ pinentry/pinentry-curses.c    | 7 +++----
+ pinentry/pinentry-emacs.c     | 2 +-
+ pinentry/pinentry.c           | 1 -
+ pinentry/pinentry.h           | 2 ++
+ secmem/Makefile.am            | 2 +-
+ secmem/secmem++.h             | 2 +-
+ secmem/secmem.c               | 2 +-
+ secmem/{memory.h => secmem.h} | 0
+ tqt/secqstring.h              | 2 +-
+ tty/pinentry-tty.c            | 1 -
+ w32/main.c                    | 1 -
+ 15 files changed, 12 insertions(+), 17 deletions(-)
+ rename secmem/{memory.h => secmem.h} (100%)
+
+--- a/fltk/main.cxx    2019-03-05 23:09:48.000000000 -0800
++++ b/fltk/main.cxx    2024-02-26 11:02:47.822134762 -0800
+@@ -34,7 +34,6 @@
+ #include <getopt.h>
+ #include <assert.h>
+ 
+-#include "memory.h"
+ #include <memory>
+ 
+ #include <pinentry.h>
+--- a/fltk/pinwindow.cxx       2017-12-03 08:13:05.000000000 -0800
++++ b/fltk/pinwindow.cxx       2024-02-26 11:02:47.822134762 -0800
+@@ -32,7 +32,7 @@
+ #include <FL/Fl_Return_Button.H>
+ #include <FL/Fl_Pixmap.H>
+ 
+-#include "memory.h"
++#include "../secmem/secmem.h"
+ 
+ #include "encrypt.xpm"
+ #include "icon.xpm"
+--- a/gnome3/pinentry-gnome3.c 2022-08-24 03:31:59.000000000 -0700
++++ b/gnome3/pinentry-gnome3.c 2024-02-26 11:02:47.822134762 -0800
+@@ -30,8 +30,6 @@
+ 
+ #include <assuan.h>
+ 
+-#include "memory.h"
+-
+ #include "pinentry.h"
+ 
+ #ifdef FALLBACK_CURSES
+--- a/pinentry/password-cache.c        2017-12-03 08:13:15.000000000 -0800
++++ b/pinentry/password-cache.c        2024-02-26 11:02:47.822134762 -0800
+@@ -31,7 +31,7 @@
+ #endif
+ 
+ #include "password-cache.h"
+-#include "memory.h"
++#include "../secmem/secmem.h"
+ 
+ #ifdef HAVE_LIBSECRET
+ static const SecretSchema *
+--- a/pinentry/pinentry.c      2022-08-24 03:31:59.000000000 -0700
++++ b/pinentry/pinentry.c      2024-02-26 11:02:47.822134762 -0800
+@@ -44,7 +44,6 @@
+ 
+ #include <assuan.h>
+ 
+-#include "memory.h"
+ #include "secmem-util.h"
+ #include "argparse.h"
+ #include "pinentry.h"
+--- a/pinentry/pinentry-curses.c       2022-08-24 03:31:59.000000000 -0700
++++ b/pinentry/pinentry-curses.c       2024-02-26 11:02:47.822134762 -0800
+@@ -62,8 +62,6 @@
+ #include <utime.h>
+ #endif /*HAVE_UTIME_H*/
+ 
+-#include <memory.h>
+-
+ #ifdef HAVE_WCHAR_H
+ #include <wchar.h>
+ #endif /*HAVE_WCHAR_H*/
+@@ -1017,10 +1015,11 @@
+ #ifndef HAVE_DOSISH_SYSTEM
+   int no_input = 1;
+ #endif
+-
+ #ifdef HAVE_NCURSESW
+   char *old_ctype = NULL;
++#endif
+ 
++#ifdef HAVE_NCURSESW
+   if (pinentry->lc_ctype)
+     {
+       old_ctype = strdup (setlocale (LC_CTYPE, NULL));
+--- a/pinentry/pinentry-emacs.c        2021-08-11 04:16:10.000000000 -0700
++++ b/pinentry/pinentry-emacs.c        2024-02-26 11:02:47.822134762 -0800
+@@ -48,7 +48,7 @@
+ #include <assuan.h>
+ 
+ #include "pinentry-emacs.h"
+-#include "memory.h"
++#include "../secmem/secmem.h"
+ #include "secmem-util.h"
+ 
+ /* The communication mechanism is similar to emacsclient, but there
+--- a/pinentry/pinentry.h      2022-08-24 03:31:59.000000000 -0700
++++ b/pinentry/pinentry.h      2024-02-26 11:02:47.822134762 -0800
+@@ -21,6 +21,8 @@
+ #ifndef PINENTRY_H
+ #define PINENTRY_H
+ 
++#include "../secmem/secmem.h"
++
+ #ifdef __cplusplus
+ extern "C" {
+ #if 0
+--- a/secmem/Makefile.am       2017-12-03 08:13:05.000000000 -0800
++++ b/secmem/Makefile.am       2024-02-26 11:02:47.822134762 -0800
+@@ -22,7 +22,7 @@
+ noinst_LIBRARIES = libsecmem.a
+ 
+ libsecmem_a_SOURCES = \
+-      memory.h \
++      secmem.h \
+       secmem-util.h \
+       util.h \
+       secmem.c \
+--- a/secmem/memory.h  2017-12-03 08:13:05.000000000 -0800
++++ b/secmem/memory.h  1969-12-31 16:00:00.000000000 -0800
+@@ -1,55 +0,0 @@
+-/* Quintuple Agent secure memory allocation
+- * Copyright (C) 1998,1999 Free Software Foundation, Inc.
+- * Copyright (C) 1999,2000 Robert Bihlmeyer <[email protected]>
+- *
+- * 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, see <https://www.gnu.org/licenses/>.
+- * SPDX-License-Identifier: GPL-2.0+
+- */
+-
+-#ifndef _MEMORY_H
+-#define _MEMORY_H
+-
+-#include <sys/types.h>
+-
+-#ifdef __cplusplus
+-extern "C" {
+-#if 0
+-}
+-#endif
+-#endif
+-
+-
+-/* values for flags, hardcoded in secmem.c */
+-#define SECMEM_WARN           0
+-#define SECMEM_DONT_WARN      1
+-#define SECMEM_SUSPEND_WARN   2
+-
+-void secmem_init( size_t npool );
+-void secmem_term( void );
+-void *secmem_malloc( size_t size );
+-void *secmem_realloc( void *a, size_t newsize );
+-void secmem_free( void *a );
+-int  m_is_secure( const void *p );
+-void secmem_dump_stats(void);
+-void secmem_set_flags( unsigned flags );
+-unsigned secmem_get_flags(void);
+-size_t secmem_get_max_size (void);
+-
+-#if 0
+-{
+-#endif
+-#ifdef __cplusplus
+-}
+-#endif
+-#endif /* _MEMORY_H */
+--- a/secmem/secmem.c  2022-08-24 03:31:59.000000000 -0700
++++ b/secmem/secmem.c  2024-02-26 11:02:47.822134762 -0800
+@@ -34,7 +34,7 @@
+ #endif
+ #include <string.h>
+ 
+-#include "memory.h"
++#include "secmem.h"
+ 
+ #ifdef ORIGINAL_GPG_VERSION
+ #include "types.h"
+--- a/secmem/secmem++.h        2017-12-03 08:13:05.000000000 -0800
++++ b/secmem/secmem++.h        2024-02-26 11:02:47.822134762 -0800
+@@ -19,7 +19,7 @@
+ #ifndef __SECMEM_SECMEMPP_H__
+ #define __SECMEM_SECMEMPP_H__
+ 
+-#include "secmem/memory.h"
++#include "../secmem/secmem.h"
+ #include <cstddef>
+ 
+ namespace secmem {
+--- a/secmem/secmem.h  1969-12-31 16:00:00.000000000 -0800
++++ b/secmem/secmem.h  2024-02-26 11:02:47.822134762 -0800
+@@ -0,0 +1,55 @@
++/* Quintuple Agent secure memory allocation
++ * Copyright (C) 1998,1999 Free Software Foundation, Inc.
++ * Copyright (C) 1999,2000 Robert Bihlmeyer <[email protected]>
++ *
++ * 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, see <https://www.gnu.org/licenses/>.
++ * SPDX-License-Identifier: GPL-2.0+
++ */
++
++#ifndef _MEMORY_H
++#define _MEMORY_H
++
++#include <sys/types.h>
++
++#ifdef __cplusplus
++extern "C" {
++#if 0
++}
++#endif
++#endif
++
++
++/* values for flags, hardcoded in secmem.c */
++#define SECMEM_WARN           0
++#define SECMEM_DONT_WARN      1
++#define SECMEM_SUSPEND_WARN   2
++
++void secmem_init( size_t npool );
++void secmem_term( void );
++void *secmem_malloc( size_t size );
++void *secmem_realloc( void *a, size_t newsize );
++void secmem_free( void *a );
++int  m_is_secure( const void *p );
++void secmem_dump_stats(void);
++void secmem_set_flags( unsigned flags );
++unsigned secmem_get_flags(void);
++size_t secmem_get_max_size (void);
++
++#if 0
++{
++#endif
++#ifdef __cplusplus
++}
++#endif
++#endif /* _MEMORY_H */
+--- a/tqt/secqstring.h 2017-12-03 08:33:12.000000000 -0800
++++ b/tqt/secqstring.h 2024-02-26 11:02:47.822134762 -0800
+@@ -65,7 +65,7 @@
+ 
+ extern "C"
+ {
+-#include "memory.h"
++#include "../secmem/secmem.h"
+ }
+ 
+ /* We need the original qchar and qstring for transparent conversion
+--- a/tty/pinentry-tty.c       2021-08-11 04:16:10.000000000 -0700
++++ b/tty/pinentry-tty.c       2024-02-26 11:02:47.822134762 -0800
+@@ -41,7 +41,6 @@
+ #include <gpg-error.h>
+ 
+ #include "pinentry.h"
+-#include "memory.h"
+ 
+ #ifndef HAVE_DOSISH_SYSTEM
+ static int timed_out;
+--- a/w32/main.c       2022-08-24 03:31:59.000000000 -0700
++++ b/w32/main.c       2024-02-26 11:02:47.822134762 -0800
+@@ -29,7 +29,6 @@
+ #endif
+ 
+ #include "pinentry.h"
+-#include "memory.h"
+ 
+ #include "resource.h"
+ /* #include "msgcodes.h" */

diff --git a/app-crypt/pinentry/pinentry-1.2.1-r6.ebuild 
b/app-crypt/pinentry/pinentry-1.2.1-r6.ebuild
new file mode 100644
index 000000000000..898f4bef6a9e
--- /dev/null
+++ b/app-crypt/pinentry/pinentry-1.2.1-r6.ebuild
@@ -0,0 +1,108 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/gnupg.asc
+inherit autotools qmake-utils verify-sig
+
+DESCRIPTION="Simple passphrase entry dialogs which utilize the Assuan protocol"
+HOMEPAGE="https://gnupg.org/aegypten2/";
+SRC_URI="mirror://gnupg/${PN}/${P}.tar.bz2"
+SRC_URI+=" verify-sig? ( mirror://gnupg/${PN}/${P}.tar.bz2.sig )"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 
~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos 
~x64-macos ~x64-solaris"
+IUSE="caps efl emacs gtk keyring ncurses qt5 wayland X"
+
+DEPEND="
+       >=dev-libs/libassuan-2.1
+       >=dev-libs/libgcrypt-1.6.3
+       >=dev-libs/libgpg-error-1.17
+       efl? ( dev-libs/efl[X] )
+       keyring? ( app-crypt/libsecret )
+       ncurses? ( sys-libs/ncurses:= )
+       qt5? (
+               dev-qt/qtcore:5
+               dev-qt/qtgui:5
+               dev-qt/qtwidgets:5
+               wayland? ( kde-plasma/kwayland:5 )
+               X? (
+                       dev-qt/qtx11extras:5
+                       x11-libs/libX11
+               )
+       )
+"
+RDEPEND="
+       ${DEPEND}
+       gtk? ( app-crypt/gcr:0[gtk] )
+"
+BDEPEND="
+       sys-devel/gettext
+       virtual/pkgconfig
+       verify-sig? ( sec-keys/openpgp-keys-gnupg )
+"
+PDEPEND="emacs? ( app-emacs/pinentry )"
+IDEPEND=">=app-eselect/eselect-pinentry-0.7.2"
+
+DOCS=( AUTHORS ChangeLog NEWS README THANKS TODO )
+
+PATCHES=(
+       "${FILESDIR}/${PN}-1.0.0-AR.patch"
+       "${FILESDIR}/${PN}-1.2.1-automagic-capslock.patch" # bug #819939, bug 
#837719
+       "${FILESDIR}/${PN}-1.2.1-include-memory.patch"
+)
+
+src_prepare() {
+       default
+
+       unset FLTK_CONFIG
+
+       eautoreconf
+}
+
+src_configure() {
+       export PATH="$(qt5_get_bindir):${PATH}"
+       export QTLIB="$(qt5_get_libdir)"
+
+       local myeconfargs=(
+               $(use_enable efl pinentry-efl)
+               $(use_enable emacs pinentry-emacs)
+               $(use_enable keyring libsecret)
+               $(use_enable gtk pinentry-gnome3)
+               $(use_enable ncurses fallback-curses)
+               $(use_enable ncurses pinentry-curses)
+               $(use_enable qt5 pinentry-qt)
+               $(use_enable wayland kf5-wayland)
+               $(use_enable X qtx11extras)
+               $(use_with X x)
+
+               --enable-pinentry-tty
+               --disable-pinentry-fltk
+               --disable-pinentry-gtk2
+
+               MOC="$(qt5_get_bindir)"/moc
+               
ac_cv_path_GPGRT_CONFIG="${ESYSROOT}/usr/bin/${CHOST}-gpgrt-config"
+
+               $("${S}/configure" --help | grep -- '--without-.*-prefix' | sed 
-e 's/^ *\([^ ]*\) .*/\1/g')
+       )
+
+       econf "${myeconfargs[@]}"
+}
+
+src_install() {
+       default
+
+       rm "${ED}"/usr/bin/pinentry || die
+
+       use qt5 && dosym pinentry-qt /usr/bin/pinentry-qt5
+}
+
+pkg_postinst() {
+       eselect pinentry update ifunset
+}
+
+pkg_postrm() {
+       eselect pinentry update ifunset
+}

Reply via email to