]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/: Include <gshadow.h> if it's available
authorAlejandro Colomar <alx@kernel.org>
Wed, 6 Nov 2024 13:19:12 +0000 (14:19 +0100)
committerAlejandro Colomar <alx@kernel.org>
Fri, 24 Jan 2025 11:10:15 +0000 (12:10 +0100)
The existing code was assuming that libc's <shadow.h> includes
<gshadow.h>.  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 <gshadow.h> 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 <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/defines.h
lib/gshadow_.h

index 8c55dddbc1622083eaa6230124d1700d693416d2..5f9ed4d1c3ce94ac78de750164b89fb742310c01 100644 (file)
 
 #include <dirent.h>
 
-/*
- * 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 <shadow.h>
-#if defined(SHADOWGRP) && !defined(GSHADOW)
+#if defined(SHADOWGRP)
 #include "gshadow_.h"
 #endif
 
index 2961afcb3aae14d197d39878e97e86cee086f401..a523308281812bfa3a65fd9c4c8c6d260b3fcbf5 100644 (file)
@@ -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 <alx@kernel.org>
+// 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 <gshadow.h>
+#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