]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
firstboot: Include <crypt.h> for declaration of crypt() if needed (#7944)
authorBjörn Esser <besser82@fedoraproject.org>
Thu, 25 Jan 2018 14:30:15 +0000 (15:30 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 25 Jan 2018 14:30:15 +0000 (17:30 +0300)
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
src/firstboot/firstboot.c

index 2e3898b3b14547d5c30c37054df125f4c4527337..fdf26f9aabd983cabb7d60a3d001cd71e9263e7a 100644 (file)
@@ -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',
index 1dbceb8803add6963b2ca2671d9441bd40db3555..262e520d5637acac47e0d7f3689ae03e33650085 100644 (file)
 #include <shadow.h>
 #include <unistd.h>
 
+#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 <crypt.h>
+#endif
+
 #include "sd-id128.h"
 
 #include "alloc-util.h"