From: Alejandro Colomar Date: Sun, 10 Nov 2024 17:52:57 +0000 (+0100) Subject: lib/shadow/, lib/, src/: getsgnam(): Move to separate file X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=51efe36f2c777b39eea06770f05194a4daded195;p=thirdparty%2Fshadow.git lib/shadow/, lib/, src/: getsgnam(): Move to separate file Signed-off-by: Alejandro Colomar --- diff --git a/lib/Makefile.am b/lib/Makefile.am index dee5e095a..300162b58 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -178,6 +178,8 @@ libshadow_la_SOURCES = \ shadow/gshadow/endsgent.h \ shadow/gshadow/fgetsgent.c \ shadow/gshadow/fgetsgent.h \ + shadow/gshadow/getsgnam.c \ + shadow/gshadow/getsgnam.h \ shadow/gshadow/gshadow.c \ shadow/gshadow/gshadow.h \ shadow/gshadow/putsgent.c \ diff --git a/lib/gshadow.c b/lib/gshadow.c index c6e1ff3ac..b16ca4764 100644 --- a/lib/gshadow.c +++ b/lib/gshadow.c @@ -38,24 +38,6 @@ } return fgetsgent(gshadow); } - -/* - * getsgnam - get a shadow group entry by name - */ - -/*@observer@*//*@null@*/struct sgrp *getsgnam (const char *name) -{ - struct sgrp *sgrp; - - setsgent (); - - while (NULL != (sgrp = getsgent())) { - if (streq(name, sgrp->sg_namp)) { - break; - } - } - return sgrp; -} #else extern int ISO_C_forbids_an_empty_translation_unit; #endif // !SHADOWGRP diff --git a/lib/gshadow_.h b/lib/gshadow_.h index ac5813610..ed7f6a9f3 100644 --- a/lib/gshadow_.h +++ b/lib/gshadow_.h @@ -20,7 +20,6 @@ /*@observer@*//*@null@*/struct sgrp *getsgent (void); -/*@observer@*//*@null@*/struct sgrp *getsgnam (const char *); #define GSHADOW "/etc/gshadow" diff --git a/lib/shadow/gshadow/getsgnam.c b/lib/shadow/gshadow/getsgnam.c new file mode 100644 index 000000000..d78a57564 --- /dev/null +++ b/lib/shadow/gshadow/getsgnam.c @@ -0,0 +1,40 @@ +// 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/getsgnam.h" + +#include +#include + +#include "defines.h" +#include "shadow/gshadow/setsgent.h" +#include "shadow/gshadow/sgrp.h" + + +/* + * getsgnam - get a shadow group entry by name + */ +#if defined(SHADOWGRP) && !__has_include() +// get shadow group entry-by-name +struct sgrp * +getsgnam(const char *name) +{ + struct sgrp *sgrp; + + setsgent (); + + while (NULL != (sgrp = getsgent ())) { + if (strcmp (name, sgrp->sg_namp) == 0) { + break; + } + } + return sgrp; +} +#endif diff --git a/lib/shadow/gshadow/getsgnam.h b/lib/shadow/gshadow/getsgnam.h new file mode 100644 index 000000000..f4acc3c41 --- /dev/null +++ b/lib/shadow/gshadow/getsgnam.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_GETSGNAM_H_ +#define SHADOW_INCLUDE_LIB_SHADOW_GSHADOW_GETSGNAM_H_ + + +#include "config.h" + +#include "shadow/gshadow/sgrp.h" + + +#if __has_include() +# include +#else +struct sgrp *getsgnam(const char *); +#endif + + +#endif // include guard diff --git a/src/newgrp.c b/src/newgrp.c index e154aba7a..51b1dcc06 100644 --- a/src/newgrp.c +++ b/src/newgrp.c @@ -28,6 +28,7 @@ #include "search/l/lsearch.h" #include "shadow/grp/agetgroups.h" #include "shadow/gshadow/endsgent.h" +#include "shadow/gshadow/getsgnam.h" #include "shadow/gshadow/sgrp.h" #include "shadowlog.h" #include "string/sprintf/snprintf.h"