From 83764f8d002afaef1492909bc4b00821eacab38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 8 Sep 2020 18:26:24 +0200 Subject: [PATCH] shared/libcrypt-util: include fewer headers Now that we wrap crypt_r/ra uses, we can include the header only in libcrypt-util.c. --- src/shared/libcrypt-util.c | 15 +++++++++++++++ src/shared/libcrypt-util.h | 14 -------------- src/test/test-libcrypt-util.c | 6 ++++++ 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/shared/libcrypt-util.c b/src/shared/libcrypt-util.c index a2f5f06bcc4..ca40c02c4ea 100644 --- a/src/shared/libcrypt-util.c +++ b/src/shared/libcrypt-util.c @@ -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 +#else +# include +#endif + #include #include diff --git a/src/shared/libcrypt-util.h b/src/shared/libcrypt-util.h index 5be4e64a52c..924a35d3e1c 100644 --- a/src/shared/libcrypt-util.h +++ b/src/shared/libcrypt-util.h @@ -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 -#endif - #include -#include int make_salt(char **ret); int hash_password_full(const char *password, void **cd_data, int *cd_size, char **ret); diff --git a/src/test/test-libcrypt-util.c b/src/test/test-libcrypt-util.c index 5c4958ed724..90abfa7b81e 100644 --- a/src/test/test-libcrypt-util.c +++ b/src/test/test-libcrypt-util.c @@ -1,5 +1,11 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ +#if HAVE_CRYPT_H +# include +#else +# include +#endif + #include "strv.h" #include "tests.h" #include "libcrypt-util.h"