From 9f555bba6740a99967f263d49282520cb74416ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Esser?= Date: Thu, 25 Jan 2018 15:30:15 +0100 Subject: [PATCH] firstboot: Include for declaration of crypt() if needed (#7944) Not every target system may provide a crypt() function in its stdlibc and may use an external or replacement library, like libxcrypt, for providing such functions. See https://fedoraproject.org/wiki/Changes/Replace_glibc_libcrypt_with_libxcrypt. --- meson.build | 3 ++- src/firstboot/firstboot.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 2e3898b..fdf26f9 100644 --- a/meson.build +++ b/meson.build @@ -589,7 +589,8 @@ conf.set('GPERF_LEN_TYPE', gperf_len_type, if not cc.has_header('sys/capability.h') error('POSIX caps headers not found') endif -foreach header : ['linux/btrfs.h', +foreach header : ['crypt.h', + 'linux/btrfs.h', 'linux/memfd.h', 'linux/vm_sockets.h', 'sys/auxv.h', diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index 1dbceb8..262e520 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -23,6 +23,19 @@ #include #include +#ifdef HAVE_CRYPT_H +/* libxcrypt is a replacement for glibc's libcrypt, and libcrypt might be + * removed from glibc at some point. As part of the removal, defines for + * crypt(3) are dropped from unistd.h, and we must include crypt.h instead. + * + * Newer versions of glibc (v2.0+) already ship crypt.h with a definition + * of crypt(3) as well, so we simply include it if it is present. MariaDB, + * MySQL, PostgreSQL, Perl and some other wide-spread packages do it the + * same way since ages without any problems. + */ +# include +#endif + #include "sd-id128.h" #include "alloc-util.h" -- 2.7.4