From: Alejandro Colomar Date: Wed, 6 Nov 2024 13:19:12 +0000 (+0100) Subject: lib/: Include if it's available X-Git-Tag: 4.17.3~55 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c30fdba8ad4eaf7daa78b74e2c2ed0909c985ea5;p=thirdparty%2Fshadow.git lib/: Include if it's available The existing code was assuming that libc's includes . That's not true. alx@debian:~$ find /usr/include/shadow.h /usr/include/shadow.h alx@debian:~$ find /usr/include/gshadow.h /usr/include/gshadow.h alx@debian:~$ grep include.*gshadow /usr/include/shadow.h alx@debian:~$ As a result, we were unconditionally including our own "gshadow_.h". Fix that incorrect assumption, and do the following instead: - Include unconditionally our own "gshadow_.h". - Make our "gshadow_.h" include if it exists, and only provide the declarations otherwise. While at it, fix the include guard to be consistent with the project. Reviewed-by: Serge Hallyn Signed-off-by: Alejandro Colomar --- diff --git a/lib/defines.h b/lib/defines.h index 8c55dddbc..5f9ed4d1c 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -50,13 +50,8 @@ #include -/* - * Possible cases: - * - /usr/include/shadow.h exists and includes the shadow group stuff. - * - /usr/include/shadow.h exists, but we use our own gshadow.h. - */ #include -#if defined(SHADOWGRP) && !defined(GSHADOW) +#if defined(SHADOWGRP) #include "gshadow_.h" #endif diff --git a/lib/gshadow_.h b/lib/gshadow_.h index 2961afcb3..a52330828 100644 --- a/lib/gshadow_.h +++ b/lib/gshadow_.h @@ -1,17 +1,17 @@ -/* - * SPDX-FileCopyrightText: 1988 - 1994, Julianne Frances Haugh - * SPDX-FileCopyrightText: 1996 - 1997, Marek Michałkiewicz - * SPDX-FileCopyrightText: 2003 - 2005, Tomasz Kłoczko - * - * SPDX-License-Identifier: BSD-3-Clause - */ +// SPDX-FileCopyrightText: 1988-1994, Julianne Frances Haugh +// SPDX-FileCopyrightText: 1996-1997, Marek Michałkiewicz +// SPDX-FileCopyrightText: 2003-2005, Tomasz Kłoczko +// SPDX-FileCopyrightText: 2024, Alejandro Colomar +// SPDX-License-Identifier: BSD-3-Clause -/* - * $Id$ - */ -#ifndef _H_GSHADOW -#define _H_GSHADOW +#ifndef SHADOW_INCLUDE_LIB_GSHADOW__H_ +#define SHADOW_INCLUDE_LIB_GSHADOW__H_ + + +#if defined(HAVE_GSHADOW_H) +# include +#else /* * Shadow group security file structure @@ -39,4 +39,7 @@ void endsgent (void); int putsgent (const struct sgrp *, FILE *); #define GSHADOW "/etc/gshadow" -#endif /* ifndef _H_GSHADOW */ + + +#endif // !HAVE_GSHADOW_H +#endif // include guard