From: Alejandro Colomar Date: Sun, 10 Nov 2024 16:44:23 +0000 (+0100) Subject: lib/shadow/, lib/: setsgent(): Move to separate file X-Git-Tag: 4.19.0-rc1~141 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbd5e1305faf71a2107e3b3f3e194d7b3632ba22;p=thirdparty%2Fshadow.git lib/shadow/, lib/: setsgent(): Move to separate file Signed-off-by: Alejandro Colomar --- diff --git a/lib/Makefile.am b/lib/Makefile.am index 74f16b376..61025b887 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -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 \ diff --git a/lib/gshadow.c b/lib/gshadow.c index eb2ea5dff..b80a82fe2 100644 --- a/lib/gshadow.c +++ b/lib/gshadow.c @@ -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) { diff --git a/lib/gshadow_.h b/lib/gshadow_.h index 618e04369..66f7a9061 100644 --- a/lib/gshadow_.h +++ b/lib/gshadow_.h @@ -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 index 000000000..73be77907 --- /dev/null +++ b/lib/shadow/gshadow/setsgent.c @@ -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 +// SPDX-License-Identifier: BSD-3-Clause + + +#include "config.h" + +#include "shadow/gshadow/setsgent.h" + +#include +#include +#include + +#include "shadow/gshadow/gshadow.h" + + +#if defined(SHADOWGRP) && !__has_include() +// 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 index 000000000..2c4435e79 --- /dev/null +++ b/lib/shadow/gshadow/setsgent.h @@ -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 +// 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() +# include +#else +void setsgent(void); +#endif + + +#endif // include guard