diff --git a/gnupg2.spec b/gnupg2.spec index c66e04e5e8548895ef7b18958728272d305efe44..39ac6ae1970f91f55f8fe4af5afa2d10e0c8ce6a 100644 --- a/gnupg2.spec +++ b/gnupg2.spec @@ -1,6 +1,10 @@ +# Define no_pinentry to 1, +# if you have no pinentry package +%define no_pinentry 0 + Name: gnupg2 Version: 2.4.3 -Release: 2 +Release: 3 Summary: Utility for secure communication and data storage License: GPLv3+ @@ -18,6 +22,7 @@ Patch7: gnupg-2.2.20-file-is-digest.patch Patch8: gnupg-2.2.21-coverity.patch Patch9: gnupg2-revert-rfc4880bis.patch Patch10: backport-dirmngr-Enable-the-call-of-ks_ldap_help_variables-wh.patch +Patch11: gpg-set-default-pinentry-mode-to-loopback.patch BuildRequires: gcc BuildRequires: zlib-devel, npth-devel, texinfo @@ -31,7 +36,9 @@ BuildRequires: gnutls-devel Requires: libgcrypt >= 1.9.4 Requires: libgpg-error >= 1.46 +%if 0%{?no_pinentry} == 0 Recommends: pinentry +%endif Recommends: gnupg2-smime Provides: gpg = %{version}-%{release} @@ -70,6 +77,9 @@ sed -i -e 's/"libpcsclite\.so"/"%{pcsclib}"/' scd/scdaemon.c --enable-g13 \ --disable-ccid-driver \ --disable-tpm2d \ +%if 0%{?no_pinentry} + --disable-gpg-default-pinentry \ +%endif --enable-large-secmem %make_build @@ -119,6 +129,9 @@ make check %changelog +* Tue Jul 9 2024 yixiangzhike - 2.4.3-3 +- gpg set default pinentry mode to loopback when have no pinentry + * Tue Jan 2 2024 yixiangzhike - 2.4.3-2 - use gpgtar to replace gpg-zip diff --git a/gpg-set-default-pinentry-mode-to-loopback.patch b/gpg-set-default-pinentry-mode-to-loopback.patch new file mode 100644 index 0000000000000000000000000000000000000000..6534f8ea2c21ec313e44642bf4850e9a6c632545 --- /dev/null +++ b/gpg-set-default-pinentry-mode-to-loopback.patch @@ -0,0 +1,348 @@ +From db537e58045211cbdd48ab45d1d323f2966b69d3 Mon Sep 17 00:00:00 2001 +From: zhangguangzhi +Date: Tue, 9 Jul 2024 14:41:17 +0800 +Subject: [PATCH] set default pinentry mode to loopback +In some cases, we don't have the pinentry package availale, +so we need to change the default way of obtaining the passphrase to +LOOPBACK. +This is achieved by adding the compilation option +"--disable-gpg-default-pinentry". + +--- + config.h.in | 3 ++ + configure | 44 ++++++++++++++++++++++++ + configure.ac | 22 ++++++++++++ + g10/delkey.c | 8 +++++ + g10/gpg.c | 5 +++ + sm/gpgsm.c | 5 +++ + tests/openpgp/delete-keys.scm | 14 ++++---- + tests/openpgp/export.scm | 2 +- + tests/openpgp/issue2929.scm | 4 +-- + tests/openpgp/quick-key-manipulation.scm | 6 ++-- + 10 files changed, 100 insertions(+), 13 deletions(-) + +diff --git a/config.h.in b/config.h.in +index cd12740..17a5493 100644 +--- a/config.h.in ++++ b/config.h.in +@@ -762,6 +762,9 @@ + /* Defined if LDAP is support */ + #undef USE_LDAP + ++/* Defined if gpg does not use pinentry by default mode */ ++#undef GPG_DEFAULT_PINENTRY_MODE_LOOPBACK ++ + /* Build with integrated libdns support */ + #undef USE_LIBDNS + +diff --git a/configure b/configure +index a4d03d2..3cf0295 100755 +--- a/configure ++++ b/configure +@@ -626,6 +626,8 @@ gt_needs= + ac_header_list= + ac_subst_vars='am__EXEEXT_FALSE + am__EXEEXT_TRUE ++GPG_DEFAULT_PINENTRY_FALSE ++GPG_DEFAULT_PINENTRY_TRUE + LTLIBOBJS + LIBOBJS + BUILD_HOSTNAME +@@ -985,6 +987,7 @@ enable_tests + enable_gnupg_builddir_envvar + enable_run_gnupg_user_socket + enable_build_timestamp ++enable_gpg_default_pinentry + ' + ac_precious_vars='build_alias + host_alias +@@ -1701,6 +1704,8 @@ Optional Features: + --disable-endian-check disable the endian check and trust the OS provided + macros + --disable-optimization disable compiler optimization ++ --disable-gpg-default-pinentry ++ disable gpg default pinentry + --enable-log-clock enable log_clock timestamps + --enable-werror append -Werror to CFLAGS + --enable-all-tests let "make check" run all tests +@@ -11130,7 +11135,40 @@ cat >>confdefs.h <<_ACEOF + #define NAME_OF_SENDMAIL "$SENDMAIL" + _ACEOF + ++# ++# Check for GPG-DEFAULT-PINENTRY ++# In some cases, gpg/gpgsm does not use pinentry by default ++# ++ ++# Check whether --enable-gpg-default-pinentry was given. ++if test "${enable_gpg_default_pinentry+set}" = set; then : ++ enableval=$enable_gpg_default_pinentry; have_gpg_default_pinentry=$enableval;if test "$enableval" = "no"; then have_gpg_default_pinentry=no; fi ++fi ++ ++if test "$have_gpg_default_pinentry" = "no"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}:WARNING: ++*** ++*** Building without default pinentry for gpg. ++***" >&5 ++$as_echo "$as_me: WARNING: ++*** ++*** Building without default pinentry for gpg. ++***" >&2;} ++fi ++ ++if test "$have_gpg_default_pinentry" = yes; then ++ GPG_DEFAULT_PINENTRY_TRUE= ++ GPG_DEFAULT_PINENTRY_FALSE='#' ++else ++ GPG_DEFAULT_PINENTRY_TRUE='#' ++ GPG_DEFAULT_PINENTRY_FALSE= ++fi ++ ++if test "$have_gpg_default_pinentry" = no ; then + ++$as_echo "#define GPG_DEFAULT_PINENTRY_MODE_LOOPBACK 1" >> confdefs.h ++ ++fi + + # + # Construct a printable name of the OS +@@ -16985,6 +17023,11 @@ if test -z "${USE_TOFU_TRUE}" && test -z "${USE_TOFU_FALSE}"; then + Usually this means the macro was only invoked conditionally." "$LINENO" 5 + fi + ++if test -z "${GPG_DEFAULT_PINENTRY_TRUE}" && test -z "${GPG_DEFAULT_PINENTRY_FALSE}"; then ++ as_fn_error $? "conditional \"GPG_DEFAULT_PINENTRY\" was never defined. ++Usually this means the macro was only invoked conditionally." "$LINENO" 5 ++fi ++ + : "${CONFIG_STATUS=./config.status}" + ac_write_fail=0 + ac_clean_files_save=$ac_clean_files +@@ -18505,6 +18548,7 @@ echo " + TLS support: $use_tls_library + TOFU support: $use_tofu + Tor support: $show_tor_support ++ GPG default pinentry:$have_gpg_default_pinentry + " + if test "$have_libtss" != no -a -z "$TPMSERVER" -a -z "$SWTPM"; then + cat <