]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/shadow/, lib/, src/: endsgent(): Move to separate file
authorAlejandro Colomar <alx@kernel.org>
Sun, 10 Nov 2024 15:48:15 +0000 (16:48 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Tue, 7 Oct 2025 09:03:09 +0000 (11:03 +0200)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/Makefile.am
lib/age.c
lib/gshadow.c
lib/gshadow_.h
lib/shadow/gshadow/endsgent.c [new file with mode: 0644]
lib/shadow/gshadow/endsgent.h [new file with mode: 0644]
src/login.c
src/newgrp.c
src/usermod.c

index fdbdc968d4986d55aba59ede89d6a68ab6582456..74f16b376a0a0de531fbed68e87fb5a497fe04f8 100644 (file)
@@ -174,6 +174,8 @@ libshadow_la_SOURCES = \
        sgroupio.h \
        shadow/grp/agetgroups.c \
        shadow/grp/agetgroups.h \
+       shadow/gshadow/endsgent.c \
+       shadow/gshadow/endsgent.h \
        shadow/gshadow/gshadow.c \
        shadow/gshadow/gshadow.h \
        shadow/gshadow/putsgent.c \
index cbaea09ebcd1e50413ea207a88126022fdca1d1d..bdb789e30db5a963505feeba05955f8f2df46e40 100644 (file)
--- a/lib/age.c
+++ b/lib/age.c
@@ -20,6 +20,7 @@
 #include "defines.h"
 #include "exitcodes.h"
 #include "prototypes.h"
+#include "shadow/gshadow/endsgent.h"
 
 
 #ident "$Id$"
index 4c5ac4191742324e0c4223c4bf1e3ba186c07e57..b88bba035354e7c4664ba3f671ca813c1a8fca86 100644 (file)
@@ -55,15 +55,6 @@ void setsgent (void)
        }
 }
 
-void endsgent (void)
-{
-       if (NULL != gshadow) {
-               fclose(gshadow);
-       }
-
-       gshadow = NULL;
-}
-
 /*@observer@*//*@null@*/struct sgrp *
 sgetsgent(const char *s)
 {
index 21fa210612c8fef5b1748552f095374f0af0b61b..618e04369ac911d0bb1488f9baf9d7a8f8bf2479 100644 (file)
@@ -35,7 +35,6 @@ struct sgrp {
 /*@observer@*//*@null@*/struct sgrp *sgetsgent (const char *);
 /*@observer@*//*@null@*/struct sgrp *fgetsgent (/*@null@*/FILE *);
 void setsgent (void);
-void endsgent (void);
 
 #define        GSHADOW "/etc/gshadow"
 
diff --git a/lib/shadow/gshadow/endsgent.c b/lib/shadow/gshadow/endsgent.c
new file mode 100644 (file)
index 0000000..5cfb2d4
--- /dev/null
@@ -0,0 +1,30 @@
+// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh
+// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz
+// SPDX-FileCopyrightText: 2005, Tomasz Kłoczko
+// SPDX-FileCopyrightText: 2008-2009, Nicolas François
+// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#include "config.h"
+
+#include "shadow/gshadow/endsgent.h"
+
+#include <stddef.h>
+#include <stdio.h>
+
+#include "shadow/gshadow/gshadow.h"
+
+
+#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
+// end-working-with shadow group entries
+void
+endsgent(void)
+{
+       if (NULL != gshadow) {
+               fclose(gshadow);
+       }
+
+       gshadow = NULL;
+}
+#endif
diff --git a/lib/shadow/gshadow/endsgent.h b/lib/shadow/gshadow/endsgent.h
new file mode 100644 (file)
index 0000000..b1cde28
--- /dev/null
@@ -0,0 +1,22 @@
+// 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
+
+
+#ifndef SHADOW_INCLUDE_LIB_SHADOW_GSHADOW_ENDSGENT_H_
+#define SHADOW_INCLUDE_LIB_SHADOW_GSHADOW_ENDSGENT_H_
+
+
+#include "config.h"
+
+
+#if __has_include(<gshadow.h>)
+# include <gshadow.h>
+#else
+void endsgent(void);
+#endif
+
+
+#endif  // include guard
index ff6b98e07c51c99605090124609058229eee0c27..7b567aae8ce53462e9a61194ec1d6c63f999e608 100644 (file)
@@ -37,6 +37,7 @@
 #include "getdef.h"
 #include "prototypes.h"
 #include "pwauth.h"
+#include "shadow/gshadow/endsgent.h"
 #include "shadowlog.h"
 #include "string/memset/memzero.h"
 #include "string/sprintf/snprintf.h"
index 0d9cb3395998a8851e303104483efbc6fea5e1ac..91cede727b99612fa90e56bf4eee8576864c7fb7 100644 (file)
@@ -27,6 +27,7 @@
 #include "search/l/lfind.h"
 #include "search/l/lsearch.h"
 #include "shadow/grp/agetgroups.h"
+#include "shadow/gshadow/endsgent.h"
 #include "shadowlog.h"
 #include "string/sprintf/snprintf.h"
 #include "string/strcmp/streq.h"
index 8295165a52fcc7de03b45bb97bad7ce158a78979..47c254750f6fa566ddc2dbf6e022030ddc515885 100644 (file)
@@ -60,6 +60,7 @@
 #ifdef WITH_TCB
 #include "tcbfuncs.h"
 #endif
+#include "shadow/gshadow/endsgent.h"
 #include "shadowlog.h"
 #include "sssd.h"
 #include "string/memset/memzero.h"