]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/shadow/, lib/: setsgent(): Move to separate file
authorAlejandro Colomar <alx@kernel.org>
Sun, 10 Nov 2024 16:44:23 +0000 (17:44 +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/gshadow.c
lib/gshadow_.h
lib/shadow/gshadow/setsgent.c [new file with mode: 0644]
lib/shadow/gshadow/setsgent.h [new file with mode: 0644]

index 74f16b376a0a0de531fbed68e87fb5a497fe04f8..61025b8876d8a26fb99538c64fec4117d4f0453d 100644 (file)
@@ -180,6 +180,8 @@ libshadow_la_SOURCES = \
        shadow/gshadow/gshadow.h \
        shadow/gshadow/putsgent.c \
        shadow/gshadow/putsgent.h \
+       shadow/gshadow/setsgent.c \
+       shadow/gshadow/setsgent.h \
        shadowio.c \
        shadowio.h \
        shadowlog.c \
index eb2ea5dffb7031eeb06f7100f62a3c0599e57ee4..b80a82fe2542c7c9e178342373084a36573e321d 100644 (file)
@@ -23,6 +23,7 @@
 #include "defines.h"
 #include "prototypes.h"
 #include "shadow/gshadow/gshadow.h"
+#include "shadow/gshadow/setsgent.h"
 #include "string/strcmp/streq.h"
 #include "string/strtok/stpsep.h"
 #include "string/strtok/strsep2arr.h"
@@ -46,15 +47,6 @@ build_list(char *s)
        return l;
 }
 
-void setsgent (void)
-{
-       if (NULL != gshadow) {
-               rewind(gshadow);
-       } else {
-               gshadow = fopen(_PATH_GSHADOW, "re");
-       }
-}
-
 /*@observer@*//*@null@*/struct sgrp *
 sgetsgent(const char *s)
 {
index 618e04369ac911d0bb1488f9baf9d7a8f8bf2479..66f7a90612536beaa76b97586f8e89d1d7c5ad51 100644 (file)
@@ -34,7 +34,6 @@ struct sgrp {
 /*@observer@*//*@null@*/struct sgrp *getsgnam (const char *);
 /*@observer@*//*@null@*/struct sgrp *sgetsgent (const char *);
 /*@observer@*//*@null@*/struct sgrp *fgetsgent (/*@null@*/FILE *);
-void setsgent (void);
 
 #define        GSHADOW "/etc/gshadow"
 
diff --git a/lib/shadow/gshadow/setsgent.c b/lib/shadow/gshadow/setsgent.c
new file mode 100644 (file)
index 0000000..73be779
--- /dev/null
@@ -0,0 +1,31 @@
+// 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/setsgent.h"
+
+#include <paths.h>
+#include <stddef.h>
+#include <stdio.h>
+
+#include "shadow/gshadow/gshadow.h"
+
+
+#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
+// set-resources-for-working-with shadow group entries
+void
+setsgent(void)
+{
+       if (NULL != gshadow) {
+               rewind(gshadow);
+       } else {
+               gshadow = fopen(_PATH_GSHADOW, "re");
+       }
+}
+#endif
diff --git a/lib/shadow/gshadow/setsgent.h b/lib/shadow/gshadow/setsgent.h
new file mode 100644 (file)
index 0000000..2c4435e
--- /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_SETSGENT_H_
+#define SHADOW_INCLUDE_LIB_SHADOW_GSHADOW_SETSGENT_H_
+
+
+#include "config.h"
+
+
+#if __has_include(<gshadow.h>)
+# include <gshadow.h>
+#else
+void setsgent(void);
+#endif
+
+
+#endif  // include guard