From ead65ba8760c4917cd4ef7064947bfa1d586b4ed Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Sun, 10 Nov 2024 19:04:06 +0100 Subject: [PATCH] lib/shadow/, lib/: getsgent(): Move to separate file Signed-off-by: Alejandro Colomar --- lib/Makefile.am | 3 ++- lib/gshadow.c | 43 ----------------------------------- lib/gshadow_.h | 4 ---- lib/shadow/gshadow/getsgent.c | 31 +++++++++++++++++++++++++ lib/shadow/gshadow/getsgent.h | 24 +++++++++++++++++++ lib/shadow/gshadow/getsgnam.c | 1 + po/POTFILES.in | 1 - 7 files changed, 58 insertions(+), 49 deletions(-) delete mode 100644 lib/gshadow.c create mode 100644 lib/shadow/gshadow/getsgent.c create mode 100644 lib/shadow/gshadow/getsgent.h diff --git a/lib/Makefile.am b/lib/Makefile.am index 300162b58..10b7d176c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -119,7 +119,6 @@ libshadow_la_SOURCES = \ groupio.c \ groupmem.c \ groupio.h \ - gshadow.c \ hushed.c \ idmapping.h \ idmapping.c \ @@ -178,6 +177,8 @@ libshadow_la_SOURCES = \ shadow/gshadow/endsgent.h \ shadow/gshadow/fgetsgent.c \ shadow/gshadow/fgetsgent.h \ + shadow/gshadow/getsgent.c \ + shadow/gshadow/getsgent.h \ shadow/gshadow/getsgnam.c \ shadow/gshadow/getsgnam.h \ shadow/gshadow/gshadow.c \ diff --git a/lib/gshadow.c b/lib/gshadow.c deleted file mode 100644 index b16ca4764..000000000 --- a/lib/gshadow.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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-License-Identifier: BSD-3-Clause - */ - -#include "config.h" - -#if defined(SHADOWGRP) && !__has_include() - -#ident "$Id$" - -#include -#include -#include -#include - -#include "defines.h" -#include "prototypes.h" -#include "shadow/gshadow/fgetsgent.h" -#include "shadow/gshadow/gshadow.h" -#include "shadow/gshadow/setsgent.h" -#include "shadow/gshadow/sgrp.h" -#include "string/strcmp/streq.h" - - -/* - * getsgent - get a single shadow group entry - */ - -/*@observer@*//*@null@*/struct sgrp *getsgent (void) -{ - if (NULL == gshadow) { - setsgent (); - } - return fgetsgent(gshadow); -} -#else -extern int ISO_C_forbids_an_empty_translation_unit; -#endif // !SHADOWGRP diff --git a/lib/gshadow_.h b/lib/gshadow_.h index ed7f6a9f3..f2015dcde 100644 --- a/lib/gshadow_.h +++ b/lib/gshadow_.h @@ -16,10 +16,6 @@ #include -#include "shadow/gshadow/sgrp.h" - - -/*@observer@*//*@null@*/struct sgrp *getsgent (void); #define GSHADOW "/etc/gshadow" diff --git a/lib/shadow/gshadow/getsgent.c b/lib/shadow/gshadow/getsgent.c new file mode 100644 index 000000000..0e4c55977 --- /dev/null +++ b/lib/shadow/gshadow/getsgent.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/getsgent.h" + +#include + +#include "shadow/gshadow/fgetsgent.h" +#include "shadow/gshadow/gshadow.h" +#include "shadow/gshadow/setsgent.h" +#include "shadow/gshadow/sgrp.h" + + +#if defined(SHADOWGRP) && !__has_include() +// get-next shadow group entry +struct sgrp * +getsgent(void) +{ + if (NULL == gshadow) { + setsgent (); + } + return fgetsgent(gshadow); +} +#endif diff --git a/lib/shadow/gshadow/getsgent.h b/lib/shadow/gshadow/getsgent.h new file mode 100644 index 000000000..6107daaa8 --- /dev/null +++ b/lib/shadow/gshadow/getsgent.h @@ -0,0 +1,24 @@ +// 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_GETSGENT_H_ +#define SHADOW_INCLUDE_LIB_SHADOW_GSHADOW_GETSGENT_H_ + + +#include "config.h" + +#include "shadow/gshadow/sgrp.h" + + +#if __has_include() +# include +#else +struct sgrp *getsgent(void); +#endif + + +#endif // include guard diff --git a/lib/shadow/gshadow/getsgnam.c b/lib/shadow/gshadow/getsgnam.c index d78a57564..86fb9ad49 100644 --- a/lib/shadow/gshadow/getsgnam.c +++ b/lib/shadow/gshadow/getsgnam.c @@ -14,6 +14,7 @@ #include #include "defines.h" +#include "shadow/gshadow/getsgent.h" #include "shadow/gshadow/setsgent.h" #include "shadow/gshadow/sgrp.h" diff --git a/po/POTFILES.in b/po/POTFILES.in index a925b2350..614415c23 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -27,7 +27,6 @@ lib/getgr_nam_gid.c lib/getrange.c lib/groupio.c lib/groupmem.c -lib/gshadow.c lib/hushed.c lib/idmapping.c lib/isexpired.c -- 2.47.3