host-mkpasswd: fix crash on Fedora 28 build host
authorStefan Becker <chemobejk@gmail.com>
Wed, 2 May 2018 09:05:08 +0000 (12:05 +0300)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Thu, 3 May 2018 19:56:20 +0000 (21:56 +0200)
crypt() is an optional glibc feature. Some distros, like Fedora 28, are
phasing it out to be replaced with libxcrypt [1]. Unfortunately this
change is only ABI compatible, not source code compatible, i.e. the code
will compile with warnings about undefined crypt(), but the resulting
binary will crash.

Follow the guidance in the Fedora bug and include crypt.h when
_XOPEN_CRYPT is not defined.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1566464

Signed-off-by: Stefan Becker <chemobejk@gmail.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/mkpasswd/mkpasswd.c

index 5820f325019e8e374642bc0bf346c9077612481d..fd16230468a453b6e66ee095105adf024255b1c0 100644 (file)
 #include <sys/time.h>
 #endif
 
+/* glibc without crypt() */
+#ifndef _XOPEN_CRYPT
+#include <crypt.h>
+#endif
+
 /* Application-specific */
 #include "utils.h"