]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/libcrypt-util: include fewer headers
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Sep 2020 16:26:24 +0000 (18:26 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 15 Sep 2020 09:52:30 +0000 (11:52 +0200)
Now that we wrap crypt_r/ra uses, we can include the header only in libcrypt-util.c.

src/shared/libcrypt-util.c
src/shared/libcrypt-util.h
src/test/test-libcrypt-util.c

index a2f5f06bcc4c3fd198a1b024d93829140777c1e6..ca40c02c4ea4c1146d34b135984da5cb8b6ac8a0 100644 (file)
@@ -1,5 +1,20 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
+#if 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>
+#else
+#  include <unistd.h>
+#endif
+
 #include <errno.h>
 #include <stdlib.h>
 
index 5be4e64a52c8bbed7899bbd7e46be42237277029..924a35d3e1ca3472a1d4326d75f8df95d6791271 100644 (file)
@@ -1,21 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
-#if 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 <stdbool.h>
-#include <stdlib.h>
 
 int make_salt(char **ret);
 int hash_password_full(const char *password, void **cd_data, int *cd_size, char **ret);
index 5c4958ed724b4200593d15bd59c0e1b235a35767..90abfa7b81e98b710bfdd849d2cc12c968e2223d 100644 (file)
@@ -1,5 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
+#if HAVE_CRYPT_H
+#  include <crypt.h>
+#else
+#  include <unistd.h>
+#endif
+
 #include "strv.h"
 #include "tests.h"
 #include "libcrypt-util.h"