Laszlo Ersek
2021-Oct-13 13:36 UTC
[Libguestfs] [PATCH 0/3] clean up Yara (version) dependency
Libguestfs now depends (optionally) on Yara >= 4.0.0. Make this explicit in the build configuration and the build documentation. Thanks, Laszlo Laszlo Ersek (3): build: fix the pkg-config identifier of the (optional) Yara library build: eliminate the AC_CHECK_LIB / AC_CHECK_HEADER tests for Yara build, docs: spell out minimum version (4.0.0) for the (optional) Yara lib docs/guestfs-building.pod | 2 +- m4/guestfs-daemon.m4 | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) base-commit: e597fc5317e018c259c75eb475cf6668e07236d1 -- 2.19.1.3.g30247aa5d201
Laszlo Ersek
2021-Oct-13 13:36 UTC
[Libguestfs] [PATCH 1/3] build: fix the pkg-config identifier of the (optional) Yara library
The upstream Yara project has always provided its "libyara/yara.pc.in" file with "Name: yara" -- ever since its introduction in commit 334bd1a671ca ("Add support for pkg-config", 2015-01-08). In spite of this, when the (optional) Yara dependency was added to libguestfs in commit 2e24129da376 ("appliance: add yara dependency", 2017-05-02), PKG_CHECK_MODULES was invoked with [libyara] as list-of-modules. (That was clearly a bug. I'm unsure what Debian calls their Yara pkg-config module, but calling it anything else than "yara" would be a distribution bug: upstream projects provide pkg-config files specifically so that dependent projects can find their dependencies *regardless of distribution*.) As a consequence, on Fedora today, the PKG_CHECK_MODULES macro always fails, and only the AC_CHECK_LIB / AC_CHECK_HEADER branch finds Yara. In a subsequent patch, we'll want to add a version requirement to the PKG_CHECK_MODULES macro invocation, so at first, fix the pkg-config identifier of Yara. Fixes: 2e24129da37656706b5a1d3b6bc83d4c089740bb Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- m4/guestfs-daemon.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/m4/guestfs-daemon.m4 b/m4/guestfs-daemon.m4 index 1728249a5fb7..0790f8848249 100644 --- a/m4/guestfs-daemon.m4 +++ b/m4/guestfs-daemon.m4 @@ -134,7 +134,7 @@ AC_CHECK_LIB([tsk],[tsk_version_print],[ ],[AC_MSG_WARN([The Sleuth Kit library (libtsk) not found])]) dnl yara library (optional) -PKG_CHECK_MODULES([YARA], [libyara],[ +PKG_CHECK_MODULES([YARA], [yara],[ AC_SUBST([YARA_CFLAGS]) AC_SUBST([YARA_LIBS]) AC_DEFINE([HAVE_YARA],[1],[yara library found at compile time.]) -- 2.19.1.3.g30247aa5d201
Laszlo Ersek
2021-Oct-13 13:36 UTC
[Libguestfs] [PATCH 2/3] build: eliminate the AC_CHECK_LIB / AC_CHECK_HEADER tests for Yara
Eliminate the AC_CHECK_LIB / AC_CHECK_HEADER tests for Yara, for the following reasons: - Upstream Yara has provided a pkg-config file since 2015, so the (now-fixed) pkg-config check should always find it, without the AC_CHECK_LIB / AC_CHECK_HEADER fallback branch. - In a subsequent patch, we'll want to test for the incompatible Yara API changes described at <https://github.com/VirusTotal/yara/wiki/Backward-incompatible-changes-in-YARA-4.0-API>. That's easy to do with pkg-config, but impossible with AC_CHECK_*, without a custom test. Namely, both AC_CHECK_DECLS and AC_CHECK_TYPES appear unable to check the parameter list of a function pointer typedef (namely YR_CALLBACK_FUNC and YR_COMPILER_CALLBACK_FUNC). And writing a dedicated test for this is overkill. Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- m4/guestfs-daemon.m4 | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/m4/guestfs-daemon.m4 b/m4/guestfs-daemon.m4 index 0790f8848249..316a811d30a9 100644 --- a/m4/guestfs-daemon.m4 +++ b/m4/guestfs-daemon.m4 @@ -138,11 +138,4 @@ PKG_CHECK_MODULES([YARA], [yara],[ AC_SUBST([YARA_CFLAGS]) AC_SUBST([YARA_LIBS]) AC_DEFINE([HAVE_YARA],[1],[yara library found at compile time.]) -],[ - AC_CHECK_LIB([yara],[yr_initialize],[ - AC_CHECK_HEADER([yara.h],[ - AC_SUBST([YARA_LIBS], [-lyara]) - AC_DEFINE([HAVE_YARA], [1], [Define to 1 if Yara library is available.]) - ], []) - ],[AC_MSG_WARN([Yara library not found])]) -]) +],[AC_MSG_WARN([Yara library not found])]) -- 2.19.1.3.g30247aa5d201
Laszlo Ersek
2021-Oct-13 13:36 UTC
[Libguestfs] [PATCH 3/3] build, docs: spell out minimum version (4.0.0) for the (optional) Yara lib
Commit e597fc5317e0 ("daemon/yara: fix undefined behavior due to Yara 4.0 API changes", 2021-10-12) prevents the daemon from using such a Yara version that precedes 4.0.0. If only yara < 4 is found, treat the library as absent, rather than attempting and failing to compile the yara module of the daemon. Note the version requirement in the documentation too. Suggested-by: Eric Blake <eblake at redhat.com> Suggested-by: Richard W.M. Jones <rjones at redhat.com> Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- docs/guestfs-building.pod | 2 +- m4/guestfs-daemon.m4 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guestfs-building.pod b/docs/guestfs-building.pod index 1f872700e367..803b89fd5ea6 100644 --- a/docs/guestfs-building.pod +++ b/docs/guestfs-building.pod @@ -387,7 +387,7 @@ Optional. For tab-completion of commands in bash. Optional. Library for filesystem forensics analysis. -=item yara +=item yara E<ge> 4.0.0 Optional. Tool for categorizing files based on their content. diff --git a/m4/guestfs-daemon.m4 b/m4/guestfs-daemon.m4 index 316a811d30a9..4dec4fa67995 100644 --- a/m4/guestfs-daemon.m4 +++ b/m4/guestfs-daemon.m4 @@ -134,7 +134,7 @@ AC_CHECK_LIB([tsk],[tsk_version_print],[ ],[AC_MSG_WARN([The Sleuth Kit library (libtsk) not found])]) dnl yara library (optional) -PKG_CHECK_MODULES([YARA], [yara],[ +PKG_CHECK_MODULES([YARA], [yara >= 4.0.0],[ AC_SUBST([YARA_CFLAGS]) AC_SUBST([YARA_LIBS]) AC_DEFINE([HAVE_YARA],[1],[yara library found at compile time.]) -- 2.19.1.3.g30247aa5d201