gnupg: patch gnupg-native to allow path relocation

GnuPG hard-codes $bindir etc and uses them to find the helper binaries, such as
gpg-agent.  This breaks if gnupg-native is reused from sstate for a different
build directory and GPG signing of packages is required.

Patch in getenv() checks for gnupg-native when returning the hardcoded paths,
and create a wrapper script which overrides GNUPG_BINDIR. There are more paths
that can be overridden, but this one is sufficient to make GnuPG work.

(From OE-Core rev: dfd69ff889ed78bf137116583d8ae351859ee203)

(From OE-Core rev: ddaf41f210f80556eca1d0acaee1e3f9cbf80122)

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ross Burton
2018-09-19 14:44:40 +01:00
committed by Richard Purdie
parent 26864d29ef
commit 64a257fa22
2 changed files with 87 additions and 1 deletions

View File

@@ -0,0 +1,81 @@
Allow the environment to override where gnupg looks for its own files. Useful in native builds.
Upstream-Status: Inappropriate [OE-specific]
Signed-off-by: Ross Burton <ross.burton@intel.com>
diff --git a/common/homedir.c b/common/homedir.c
index e9e75d01e..19140aa0d 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -760,7 +760,7 @@ gnupg_socketdir (void)
if (!name)
{
unsigned int dummy;
- name = _gnupg_socketdir_internal (0, &dummy);
+ name = getenv("GNUPG_SOCKETDIR") ?: _gnupg_socketdir_internal (0, &dummy);
}
return name;
@@ -786,7 +786,7 @@ gnupg_sysconfdir (void)
}
return name;
#else /*!HAVE_W32_SYSTEM*/
- return GNUPG_SYSCONFDIR;
+ return getenv("GNUPG_SYSCONFDIR") ?: GNUPG_SYSCONFDIR;
#endif /*!HAVE_W32_SYSTEM*/
}
@@ -815,7 +815,7 @@ gnupg_bindir (void)
else
return rdir;
#else /*!HAVE_W32_SYSTEM*/
- return GNUPG_BINDIR;
+ return getenv("GNUPG_BINDIR") ?: GNUPG_BINDIR;
#endif /*!HAVE_W32_SYSTEM*/
}
@@ -828,7 +828,7 @@ gnupg_libexecdir (void)
#ifdef HAVE_W32_SYSTEM
return gnupg_bindir ();
#else /*!HAVE_W32_SYSTEM*/
- return GNUPG_LIBEXECDIR;
+ return getenv("GNUPG_LIBEXECDIR") ?: GNUPG_LIBEXECDIR;
#endif /*!HAVE_W32_SYSTEM*/
}
@@ -842,7 +842,7 @@ gnupg_libdir (void)
name = xstrconcat (w32_rootdir (), DIRSEP_S "lib" DIRSEP_S "gnupg", NULL);
return name;
#else /*!HAVE_W32_SYSTEM*/
- return GNUPG_LIBDIR;
+ return getenv("GNUPG_LIBDIR") ?: GNUPG_LIBDIR;
#endif /*!HAVE_W32_SYSTEM*/
}
@@ -856,7 +856,7 @@ gnupg_datadir (void)
name = xstrconcat (w32_rootdir (), DIRSEP_S "share" DIRSEP_S "gnupg", NULL);
return name;
#else /*!HAVE_W32_SYSTEM*/
- return GNUPG_DATADIR;
+ return getenv("GNUPG_DATADIR") ?: GNUPG_DATADIR;
#endif /*!HAVE_W32_SYSTEM*/
}
@@ -872,7 +872,7 @@ gnupg_localedir (void)
NULL);
return name;
#else /*!HAVE_W32_SYSTEM*/
- return LOCALEDIR;
+ return getenv("LOCALEDIR") ?: LOCALEDIR;
#endif /*!HAVE_W32_SYSTEM*/
}
@@ -940,7 +940,7 @@ gnupg_cachedir (void)
}
return dir;
#else /*!HAVE_W32_SYSTEM*/
- return GNUPG_LOCALSTATEDIR "/cache/" PACKAGE_NAME;
+ return getenv("GNUPG_LOCALSTATEDIR") ?: GNUPG_LOCALSTATEDIR "/cache/" PACKAGE_NAME;
#endif /*!HAVE_W32_SYSTEM*/
}

View File

@@ -17,7 +17,8 @@ SRC_URI = "${GNUPG_MIRROR}/${BPN}/${BPN}-${PV}.tar.bz2 \
file://CVE-2018-12020.patch \
file://CVE-2018-9234.patch \
"
SRC_URI_append_class-native = " file://0001-configure.ac-use-a-custom-value-for-the-location-of-.patch"
SRC_URI_append_class-native = " file://0001-configure.ac-use-a-custom-value-for-the-location-of-.patch \
file://relocate.patch"
SRC_URI[md5sum] = "709e5af5bba84d251c520222e720972f"
@@ -45,6 +46,10 @@ do_install_append() {
ln -sf gpgv2 ${D}${bindir}/gpgv
}
do_install_append_class-native() {
create_wrapper ${D}${bindir}/gpg2 GNUPG_BINDIR=${STAGING_BINDIR_NATIVE}
}
PACKAGECONFIG ??= "gnutls"
PACKAGECONFIG[gnutls] = "--enable-gnutls, --disable-gnutls, gnutls"
PACKAGECONFIG[sqlite3] = "--enable-sqlite, --disable-sqlite, sqlite3"