Richard W.M. Jones
2018-Jan-23 11:50 UTC
[Libguestfs] [PATCH] customize: Use libxcrypt if available to provide crypt(3).
glibc 2.27 removes crypt(3) and suggests using libxcrypt. libxcrypt requires <crypt.h> to be included. --- customize/Makefile.am | 1 + customize/crypt-c.c | 4 ++++ m4/guestfs-misc-libraries.m4 | 27 +++++++++++++++++++-------- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/customize/Makefile.am b/customize/Makefile.am index b4ec9286a..a22e25c46 100644 --- a/customize/Makefile.am +++ b/customize/Makefile.am @@ -100,6 +100,7 @@ libcustomize_a_CPPFLAGS = \ -I$(top_srcdir)/common/edit libcustomize_a_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) \ + $(LIBCRYPT_CFLAGS) \ $(LIBVIRT_CFLAGS) \ $(LIBXML2_CFLAGS) \ -fPIC diff --git a/customize/crypt-c.c b/customize/crypt-c.c index 70e6ea7f5..d5425cfaa 100644 --- a/customize/crypt-c.c +++ b/customize/crypt-c.c @@ -22,6 +22,10 @@ #include <stdlib.h> #include <unistd.h> +#if HAVE_CRYPT_H +#include <crypt.h> +#endif + #include <caml/alloc.h> #include <caml/memory.h> #include <caml/mlvalues.h> diff --git a/m4/guestfs-misc-libraries.m4 b/m4/guestfs-misc-libraries.m4 index 2f371873f..f05a56fb8 100644 --- a/m4/guestfs-misc-libraries.m4 +++ b/m4/guestfs-misc-libraries.m4 @@ -17,14 +17,25 @@ dnl Miscellaneous libraries used by other programs. -dnl Check if crypt() is provided by a separate library. -old_LIBS="$LIBS" -AC_SEARCH_LIBS([crypt],[crypt]) -LIBS="$old_LIBS" -if test "$ac_cv_search_crypt" = "-lcrypt" ; then - LIBCRYPT_LIBS="-lcrypt" -fi -AC_SUBST([LIBCRYPT_LIBS]) +dnl glibc 2.27 removes crypt(3) and suggests using libxcrypt. +PKG_CHECK_MODULES([LIBCRYPT], [libxcrypt], [ + AC_SUBST([LIBCRYPT_CFLAGS]) + AC_SUBST([LIBCRYPT_LIBS]) +],[ + dnl Check if crypt() is provided by another library. + old_LIBS="$LIBS" + AC_SEARCH_LIBS([crypt],[crypt]) + LIBS="$old_LIBS" + if test "$ac_cv_search_crypt" = "-lcrypt" ; then + LIBCRYPT_LIBS="-lcrypt" + fi + AC_SUBST([LIBCRYPT_LIBS]) +]) + +dnl Do we need to include <crypt.h>? +old_CFLAGS="$CFLAGS" +AC_CHECK_HEADERS([crypt.h]) +CFLAGS="$old_CFLAGS" dnl liblzma can be used by virt-builder (optional). PKG_CHECK_MODULES([LIBLZMA], [liblzma], [ -- 2.13.2
Richard W.M. Jones
2018-Jan-23 11:56 UTC
Re: [Libguestfs] [PATCH] customize: Use libxcrypt if available to provide crypt(3).
Sorry, there was a small mistake. Instead of posting the patch again, the difference is: --- a/m4/guestfs-misc-libraries.m4 +++ b/m4/guestfs-misc-libraries.m4 @@ -34,6 +34,7 @@ PKG_CHECK_MODULES([LIBCRYPT], [libxcrypt], [ dnl Do we need to include <crypt.h>? old_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $LIBCRYPT_CFLAGS" AC_CHECK_HEADERS([crypt.h]) CFLAGS="$old_CFLAGS" Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Maybe Matching Threads
- [PATCH 2/2] lib: Check if crypt() comes from a separate library
- [PATCH supermin v2 1/4] init: Uncompress modules before adding them to the mini initrd.
- [PATCH 1/2] run: Set DYLD_LIBRARY_PATH along with LD_LIBRARY_PATH
- [PATCH 1/2] build: factor out the OCaml link.sh scripts
- make check (pigeonhole)