diff --git a/lib/Makefile.am b/lib/Makefile.am index dc67df9e8..b925a038b 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -118,7 +118,6 @@ libshadow_la_SOURCES = \ groupio.c \ groupmem.c \ groupio.h \ - gshadow.c \ hushed.c \ idmapping.h \ idmapping.c \ @@ -167,14 +166,34 @@ libshadow_la_SOURCES = \ semanage.c \ setugid.c \ setupenv.c \ - sgetgrent.c \ - sgetpwent.c \ sgetspent.c \ sgroupio.c \ - sgroupio.h\ + sgroupio.h \ shadow.c \ + shadow/group/sgetgrent.c \ + shadow/group/sgetgrent.h \ shadow/grp/agetgroups.c \ shadow/grp/agetgroups.h \ + shadow/gshadow/endsgent.c \ + 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 \ + shadow/gshadow/gshadow.h \ + shadow/gshadow/putsgent.c \ + shadow/gshadow/putsgent.h \ + shadow/gshadow/setsgent.c \ + shadow/gshadow/setsgent.h \ + shadow/gshadow/sgetsgent.c \ + shadow/gshadow/sgetsgent.h \ + shadow/gshadow/sgrp.c \ + shadow/gshadow/sgrp.h \ + shadow/passwd/sgetpwent.c \ + shadow/passwd/sgetpwent.h \ shadowio.c \ shadowio.h \ shadowlog.c \ @@ -279,5 +298,4 @@ endif EXTRA_DIST = \ .indent.pro \ - gshadow_.h \ xgetXXbyYY.c diff --git a/lib/age.c b/lib/age.c index ff2aebe2b..b7ad6bcf7 100644 --- 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$" diff --git a/lib/defines.h b/lib/defines.h index 89300c93c..887f28824 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -51,9 +51,6 @@ #include #include -#if defined(SHADOWGRP) -#include "gshadow_.h" -#endif #include @@ -164,12 +161,6 @@ #define SUBGID_FILE "/etc/subgid" #endif -#ifdef SHADOWGRP -#ifndef SGROUP_FILE -#define SGROUP_FILE "/etc/gshadow" -#endif -#endif - /* * string to use for the pw_passwd field in /etc/passwd when using * shadow passwords - most systems use "x" but there are a few diff --git a/lib/groupio.c b/lib/groupio.c index 516e3ccd2..66afe9a07 100644 --- a/lib/groupio.c +++ b/lib/groupio.c @@ -22,6 +22,7 @@ #include "getdef.h" #include "groupio.h" #include "prototypes.h" +#include "shadow/group/sgetgrent.h" #include "string/strcmp/streq.h" diff --git a/lib/gshadow.c b/lib/gshadow.c deleted file mode 100644 index 2725e09eb..000000000 --- a/lib/gshadow.c +++ /dev/null @@ -1,278 +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 - -#if defined(SHADOWGRP) && !__has_include() - -#ident "$Id$" - -#include -#include -#include - -#include "alloc/malloc.h" -#include "alloc/realloc.h" -#include "alloc/x/xmalloc.h" -#include "defines.h" -#include "prototypes.h" -#include "string/strchr/strchrcnt.h" -#include "string/strcmp/streq.h" -#include "string/strtok/stpsep.h" - - -static /*@null@*/FILE *shadow; -static struct sgrp sgroup = {}; - -#define FIELDS 4 - - -static /*@null@*/char ** -build_list(char *s) -{ - char **l; - size_t i; - - l = XMALLOC(strchrcnt(s, ',') + 2, char *); - - for (i = 0; s != NULL && !streq(s, ""); i++) - l[i] = strsep(&s, ","); - - l[i] = NULL; - - return l; -} - -void setsgent (void) -{ - if (NULL != shadow) { - rewind (shadow); - } else { - shadow = fopen (SGROUP_FILE, "re"); - } -} - -void endsgent (void) -{ - if (NULL != shadow) { - (void) fclose (shadow); - } - - shadow = NULL; -} - -/*@observer@*//*@null@*/struct sgrp * -sgetsgent(const char *string) -{ - static char *sgrbuf = NULL; - static size_t sgrbuflen = 0; - - char *fields[FIELDS]; - char *cp; - int i; - size_t len = strlen (string) + 1; - - if (len > sgrbuflen) { - char *buf = REALLOC(sgrbuf, len, char); - if (NULL == buf) - return NULL; - - sgrbuf = buf; - sgrbuflen = len; - } - - strcpy (sgrbuf, string); - stpsep(sgrbuf, "\n"); - - /* - * There should be exactly 4 colon separated fields. Find - * all 4 of them and save the starting addresses in fields[]. - */ - - for (cp = sgrbuf, i = 0; (i < FIELDS) && (NULL != cp); i++) - fields[i] = strsep(&cp, ":"); - - /* - * If there was an extra field somehow, or perhaps not enough, - * the line is invalid. - */ - - if (NULL != cp || i != FIELDS) - return NULL; - - sgroup.sg_namp = fields[0]; - sgroup.sg_passwd = fields[1]; - - free(sgroup.sg_adm); - free(sgroup.sg_mem); - - sgroup.sg_adm = build_list(fields[2]); - sgroup.sg_mem = build_list(fields[3]); - - return &sgroup; -} - -/* - * fgetsgent - convert next line in stream to (struct sgrp) - * - * fgetsgent() reads the next line from the provided stream and - * converts it to a (struct sgrp). NULL is returned on EOF. - */ - -/*@observer@*//*@null@*/struct sgrp *fgetsgent (/*@null@*/FILE * fp) -{ - static size_t buflen = 0; - static char *buf = NULL; - - char *cp; - - if (0 == buflen) { - buf = MALLOC(BUFSIZ, char); - if (NULL == buf) { - return NULL; - } - buflen = BUFSIZ; - } - - if (NULL == fp) { - return NULL; - } - - if (fgetsx(buf, buflen, fp) == NULL) - return NULL; - - while ( (strrchr(buf, '\n') == NULL) - && (feof (fp) == 0)) { - size_t len; - - cp = REALLOC(buf, buflen * 2, char); - if (NULL == cp) { - return NULL; - } - buf = cp; - buflen *= 2; - - len = strlen (buf); - if (fgetsx (&buf[len], - (int) (buflen - len), - fp) != &buf[len]) { - return NULL; - } - } - stpsep(buf, "\n"); - return (sgetsgent (buf)); -} - -/* - * getsgent - get a single shadow group entry - */ - -/*@observer@*//*@null@*/struct sgrp *getsgent (void) -{ - if (NULL == shadow) { - setsgent (); - } - return (fgetsgent (shadow)); -} - -/* - * getsgnam - get a shadow group entry by name - */ - -/*@observer@*//*@null@*/struct sgrp *getsgnam (const char *name) -{ - struct sgrp *sgrp; - - setsgent (); - - while ((sgrp = getsgent ()) != NULL) { - if (streq(name, sgrp->sg_namp)) { - break; - } - } - return sgrp; -} - -/* - * putsgent - output shadow group entry in text form - * - * putsgent() converts the contents of a (struct sgrp) to text and - * writes the result to the given stream. This is the logical - * opposite of fgetsgent. - */ - -int putsgent (const struct sgrp *sgrp, FILE * fp) -{ - char *buf, *cp; - int i; - size_t size; - - if ((NULL == fp) || (NULL == sgrp)) { - return -1; - } - - /* calculate the required buffer size */ - size = strlen (sgrp->sg_namp) + strlen (sgrp->sg_passwd) + 10; - for (i = 0; (NULL != sgrp->sg_adm) && (NULL != sgrp->sg_adm[i]); i++) { - size += strlen (sgrp->sg_adm[i]) + 1; - } - for (i = 0; (NULL != sgrp->sg_mem) && (NULL != sgrp->sg_mem[i]); i++) { - size += strlen (sgrp->sg_mem[i]) + 1; - } - - buf = MALLOC(size, char); - if (NULL == buf) { - return -1; - } - cp = buf; - - /* - * Copy the group name and passwd. - */ - cp = stpcpy(stpcpy(cp, sgrp->sg_namp), ":"); - cp = stpcpy(stpcpy(cp, sgrp->sg_passwd), ":"); - - /* - * Copy the administrators, separating each from the other - * with a ",". - */ - for (i = 0; NULL != sgrp->sg_adm[i]; i++) { - if (i > 0) - cp = stpcpy(cp, ","); - - cp = stpcpy(cp, sgrp->sg_adm[i]); - } - cp = stpcpy(cp, ":"); - - /* - * Now do likewise with the group members. - */ - for (i = 0; NULL != sgrp->sg_mem[i]; i++) { - if (i > 0) - cp = stpcpy(cp, ","); - - cp = stpcpy(cp, sgrp->sg_mem[i]); - } - stpcpy(cp, "\n"); - - /* - * Output using the function which understands the line - * continuation conventions. - */ - if (fputsx (buf, fp) == EOF) { - free (buf); - return -1; - } - - free (buf); - return 0; -} -#else -extern int ISO_C_forbids_an_empty_translation_unit; -#endif // !SHADOWGRP diff --git a/lib/gshadow_.h b/lib/gshadow_.h deleted file mode 100644 index 2b38cb338..000000000 --- a/lib/gshadow_.h +++ /dev/null @@ -1,45 +0,0 @@ -// 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_GSHADOW__H_ -#define SHADOW_INCLUDE_LIB_GSHADOW__H_ - - -#if __has_include() -# include -#else - -/* - * Shadow group security file structure - */ - -struct sgrp { - char *sg_namp; /* group name */ - char *sg_passwd; /* group password */ - char **sg_adm; /* group administrator list */ - char **sg_mem; /* group membership list */ -}; - -/* - * Shadow group security file functions. - */ - -#include /* for FILE */ - -/*@observer@*//*@null@*/struct sgrp *getsgent (void); -/*@observer@*//*@null@*/struct sgrp *getsgnam (const char *); -/*@observer@*//*@null@*/struct sgrp *sgetsgent (const char *); -/*@observer@*//*@null@*/struct sgrp *fgetsgent (/*@null@*/FILE *); -void setsgent (void); -void endsgent (void); -int putsgent (const struct sgrp *, FILE *); - -#define GSHADOW "/etc/gshadow" - - -#endif // !__has_include() -#endif // include guard diff --git a/lib/prefix_flag.c b/lib/prefix_flag.c index c09b8d082..38491986d 100644 --- a/lib/prefix_flag.c +++ b/lib/prefix_flag.c @@ -27,6 +27,7 @@ #include "subordinateio.h" #endif /* ENABLE_SUBIDS */ #include "getdef.h" +#include "shadow/gshadow/gshadow.h" #include "shadowlog.h" #include "string/sprintf/xasprintf.h" #include "string/strcmp/streq.h" @@ -116,7 +117,7 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char ** gr_setdbname(group_db_file); #ifdef SHADOWGRP - xasprintf(&sgroup_db_file, "%s/%s", prefix, SGROUP_FILE); + xasprintf(&sgroup_db_file, "%s/%s", prefix, GSHADOW_FILE); sgr_setdbname(sgroup_db_file); #endif diff --git a/lib/prototypes.h b/lib/prototypes.h index 79bd0fdd6..76ec3a3ed 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -34,6 +34,8 @@ #include "attr.h" #include "defines.h" #include "commonio.h" +#include "shadow/gshadow/sgrp.h" + /* addgrps.c */ #if !defined(USE_PAM) @@ -396,12 +398,6 @@ extern void setup (struct passwd *); /* setupenv.c */ extern void setup_env (struct passwd *); -/* sgetgrent.c */ -extern struct group *sgetgrent (const char *buf); - -/* sgetpwent.c */ -extern struct passwd *sgetpwent (const char *buf); - /* sgetspent.c */ #ifndef HAVE_SGETSPENT extern struct spwd *sgetspent (const char *string); diff --git a/lib/pwio.c b/lib/pwio.c index 3497c7545..59de8fcb9 100644 --- a/lib/pwio.c +++ b/lib/pwio.c @@ -18,6 +18,8 @@ #include #include "commonio.h" #include "pwio.h" +#include "shadow/passwd/sgetpwent.h" + static /*@null@*/ /*@only@*/void *passwd_dup (const void *ent) { diff --git a/lib/sgroupio.c b/lib/sgroupio.c index 980576124..c6c26dbe5 100644 --- a/lib/sgroupio.c +++ b/lib/sgroupio.c @@ -21,6 +21,10 @@ #include "commonio.h" #include "getdef.h" #include "sgroupio.h" +#include "shadow/gshadow/gshadow.h" +#include "shadow/gshadow/putsgent.h" +#include "shadow/gshadow/sgetsgent.h" +#include "shadow/gshadow/sgrp.h" #include "string/memset/memzero.h" @@ -204,7 +208,7 @@ static struct commonio_ops gshadow_ops = { }; static struct commonio_db gshadow_db = { - SGROUP_FILE, /* filename */ + GSHADOW_FILE, /* filename */ &gshadow_ops, /* ops */ NULL, /* fp */ #ifdef WITH_SELINUX diff --git a/lib/sgroupio.h b/lib/sgroupio.h index 3474a985b..e0ae944d5 100644 --- a/lib/sgroupio.h +++ b/lib/sgroupio.h @@ -12,6 +12,12 @@ #ifndef _SGROUPIO_H #define _SGROUPIO_H + +#include + +#include "shadow/gshadow/sgrp.h" + + extern int sgr_close (void); extern bool sgr_file_present (void); extern /*@observer@*/ /*@null@*/const struct sgrp *sgr_locate (const char *name); diff --git a/lib/sgetgrent.c b/lib/shadow/group/sgetgrent.c similarity index 83% rename from lib/sgetgrent.c rename to lib/shadow/group/sgetgrent.c index eeeed4b6f..7432b3be2 100644 --- a/lib/sgetgrent.c +++ b/lib/shadow/group/sgetgrent.c @@ -1,15 +1,14 @@ -/* - * SPDX-FileCopyrightText: 1990 - 1994, Julianne Frances Haugh - * SPDX-FileCopyrightText: 1996 - 1998, Marek Michałkiewicz - * SPDX-FileCopyrightText: 2005 , Tomasz Kłoczko - * SPDX-FileCopyrightText: 2008 , Nicolas François - * - * SPDX-License-Identifier: BSD-3-Clause - */ +// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh +// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz +// SPDX-FileCopyrightText: 2005, Tomasz Kłoczko +// SPDX-FileCopyrightText: 2008, Nicolas François +// SPDX-FileCopyrightText: 2024, Alejandro Colomar +// SPDX-License-Identifier: BSD-3-Clause + #include -#ident "$Id$" +#include "shadow/group/sgetgrent.h" #include #include @@ -27,6 +26,7 @@ #define NFIELDS 4 + /* * list - turn a comma-separated string into an array of (char *)'s * @@ -64,7 +64,8 @@ list(char *s) } -struct group *sgetgrent (const char *buf) +struct group * +sgetgrent(const char *buf) { static char *grpbuf = NULL; static size_t size = 0; @@ -105,4 +106,3 @@ struct group *sgetgrent (const char *buf) return &grent; } - diff --git a/lib/shadow/group/sgetgrent.h b/lib/shadow/group/sgetgrent.h new file mode 100644 index 000000000..460e3c7cd --- /dev/null +++ b/lib/shadow/group/sgetgrent.h @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: 2024, Alejandro Colomar +// SPDX-License-Identifier: BSD-3-Clause + + +#ifndef SHADOW_INCLUDE_LIB_SHADOW_GROUP_SGETGRENT_H_ +#define SHADOW_INCLUDE_LIB_SHADOW_GROUP_SGETGRENT_H_ + + +#include + +#include + + +struct group *sgetgrent(const char *s); + + +#endif // include guard diff --git a/lib/shadow/gshadow/endsgent.c b/lib/shadow/gshadow/endsgent.c new file mode 100644 index 000000000..59a5160a7 --- /dev/null +++ b/lib/shadow/gshadow/endsgent.c @@ -0,0 +1,29 @@ +// 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 + +#include "shadow/gshadow/endsgent.h" + +#include +#include + +#include "shadow/gshadow/gshadow.h" + + +#if defined(SHADOWGRP) && !__has_include() +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 index 000000000..056b4a70a --- /dev/null +++ b/lib/shadow/gshadow/endsgent.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_ENDSGENT_H_ +#define SHADOW_INCLUDE_LIB_SHADOW_GSHADOW_ENDSGENT_H_ + + +#include + + +#if __has_include() +# include +#else +void endsgent(void); +#endif + + +#endif // include guard diff --git a/lib/shadow/gshadow/fgetsgent.c b/lib/shadow/gshadow/fgetsgent.c new file mode 100644 index 000000000..4c05a7456 --- /dev/null +++ b/lib/shadow/gshadow/fgetsgent.c @@ -0,0 +1,77 @@ +// 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 + +#include "shadow/gshadow/fgetsgent.h" + +#include +#include +#include + +#include "alloc/malloc.h" +#include "alloc/realloc.h" +#include "defines.h" +#include "prototypes.h" +#include "shadow/gshadow/sgetsgent.h" +#include "shadow/gshadow/sgrp.h" +#include "string/strtok/stpsep.h" + + +/* + * fgetsgent - convert next line in stream to (struct sgrp) + * + * fgetsgent() reads the next line from the provided stream and + * converts it to a (struct sgrp). NULL is returned on EOF. + */ +#if defined(SHADOWGRP) && !__has_include() +struct sgrp * +fgetsgent(FILE *fp) +{ + static size_t buflen = 0; + static char *buf = NULL; + + char *cp; + + if (0 == buflen) { + buf = MALLOC(BUFSIZ, char); + if (NULL == buf) { + return NULL; + } + buflen = BUFSIZ; + } + + if (NULL == fp) { + return NULL; + } + + if (fgetsx(buf, buflen, fp) == NULL) + return NULL; + + while ( (strrchr(buf, '\n') == NULL) + && (feof (fp) == 0)) { + size_t len; + + cp = REALLOC(buf, buflen * 2, char); + if (NULL == cp) { + return NULL; + } + buf = cp; + buflen *= 2; + + len = strlen (buf); + if (fgetsx (&buf[len], + (int) (buflen - len), + fp) != &buf[len]) { + return NULL; + } + } + stpsep(buf, "\n"); + return sgetsgent(buf); +} +#endif diff --git a/lib/shadow/gshadow/fgetsgent.h b/lib/shadow/gshadow/fgetsgent.h new file mode 100644 index 000000000..bb74dbc0d --- /dev/null +++ b/lib/shadow/gshadow/fgetsgent.h @@ -0,0 +1,26 @@ +// 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_FGETSGENT_H_ +#define SHADOW_INCLUDE_LIB_SHADOW_GSHADOW_FGETSGENT_H_ + + +#include + +#include + +#include "shadow/gshadow/sgrp.h" + + +#if __has_include() +# include +#else +struct sgrp *fgetsgent(FILE *stream); +#endif + + +#endif // include guard diff --git a/lib/shadow/gshadow/getsgent.c b/lib/shadow/gshadow/getsgent.c new file mode 100644 index 000000000..03bf3dc8a --- /dev/null +++ b/lib/shadow/gshadow/getsgent.c @@ -0,0 +1,33 @@ +// 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 + +#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() +/* + * getsgent - get a single 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..b8efde1b0 --- /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 + +#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 new file mode 100644 index 000000000..d762cd4d3 --- /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 + +#include "shadow/gshadow/getsgnam.h" + +#include +#include + +#include "defines.h" +#include "shadow/gshadow/getsgent.h" +#include "shadow/gshadow/setsgent.h" +#include "shadow/gshadow/sgrp.h" + + +/* + * getsgnam - get a shadow group entry by name + */ +#if defined(SHADOWGRP) && !__has_include() +struct sgrp * +getsgnam(const char *name) +{ + struct sgrp *sgrp; + + setsgent (); + + while ((sgrp = getsgent ()) != NULL) { + 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..a0ba166ed --- /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 + +#include "shadow/gshadow/sgrp.h" + + +#if __has_include() +# include +#else +struct sgrp *getsgnam(const char *); +#endif + + +#endif // include guard diff --git a/lib/shadow/gshadow/gshadow.c b/lib/shadow/gshadow/gshadow.c new file mode 100644 index 000000000..ea81486a9 --- /dev/null +++ b/lib/shadow/gshadow/gshadow.c @@ -0,0 +1,17 @@ +// 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 + +#include "shadow/gshadow/gshadow.h" + +#include +#include + + +FILE *gshadow = NULL; diff --git a/lib/shadow/gshadow/gshadow.h b/lib/shadow/gshadow/gshadow.h new file mode 100644 index 000000000..3786f6ddb --- /dev/null +++ b/lib/shadow/gshadow/gshadow.h @@ -0,0 +1,25 @@ +// 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_GSHADOW_H_ +#define SHADOW_INCLUDE_LIB_SHADOW_GSHADOW_GSHADOW_H_ + + +#include + +#include + +#include "shadow/gshadow/gshadow.h" + + +#define GSHADOW_FILE "/etc/gshadow" + + +extern FILE *gshadow; + + +#endif // include guard diff --git a/lib/shadow/gshadow/putsgent.c b/lib/shadow/gshadow/putsgent.c new file mode 100644 index 000000000..69ac0bfc9 --- /dev/null +++ b/lib/shadow/gshadow/putsgent.c @@ -0,0 +1,98 @@ +// 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 + +#include "shadow/gshadow/putsgent.h" + +#include +#include +#include +#include + +#include "alloc/malloc.h" +#include "prototypes.h" +#include "shadow/gshadow/sgrp.h" + + +/* + * putsgent - output shadow group entry in text form + * + * putsgent() converts the contents of a (struct sgrp) to text and + * writes the result to the given stream. This is the logical + * opposite of fgetsgent. + */ +#if defined(SHADOWGRP) && !__has_include() +int +putsgent(const struct sgrp *sgrp, FILE *fp) +{ + char *buf, *cp; + int i; + size_t size; + + if ((NULL == fp) || (NULL == sgrp)) { + return -1; + } + + /* calculate the required buffer size */ + size = strlen (sgrp->sg_namp) + strlen (sgrp->sg_passwd) + 10; + for (i = 0; (NULL != sgrp->sg_adm) && (NULL != sgrp->sg_adm[i]); i++) { + size += strlen (sgrp->sg_adm[i]) + 1; + } + for (i = 0; (NULL != sgrp->sg_mem) && (NULL != sgrp->sg_mem[i]); i++) { + size += strlen (sgrp->sg_mem[i]) + 1; + } + + buf = MALLOC(size, char); + if (NULL == buf) { + return -1; + } + cp = buf; + + /* + * Copy the group name and passwd. + */ + cp = stpcpy(stpcpy(cp, sgrp->sg_namp), ":"); + cp = stpcpy(stpcpy(cp, sgrp->sg_passwd), ":"); + + /* + * Copy the administrators, separating each from the other + * with a ",". + */ + for (i = 0; NULL != sgrp->sg_adm[i]; i++) { + if (i > 0) + cp = stpcpy(cp, ","); + + cp = stpcpy(cp, sgrp->sg_adm[i]); + } + cp = stpcpy(cp, ":"); + + /* + * Now do likewise with the group members. + */ + for (i = 0; NULL != sgrp->sg_mem[i]; i++) { + if (i > 0) + cp = stpcpy(cp, ","); + + cp = stpcpy(cp, sgrp->sg_mem[i]); + } + stpcpy(cp, "\n"); + + /* + * Output using the function which understands the line + * continuation conventions. + */ + if (fputsx (buf, fp) == EOF) { + free (buf); + return -1; + } + + free (buf); + return 0; +} +#endif diff --git a/lib/shadow/gshadow/putsgent.h b/lib/shadow/gshadow/putsgent.h new file mode 100644 index 000000000..38c669919 --- /dev/null +++ b/lib/shadow/gshadow/putsgent.h @@ -0,0 +1,26 @@ +// 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_PUTSGENT_H_ +#define SHADOW_INCLUDE_LIB_SHADOW_GSHADOW_PUTSGENT_H_ + + +#include + +#include + +#include "shadow/gshadow/sgrp.h" + + +#if __has_include() +# include +#else +int putsgent(const struct sgrp *sgrp, FILE *fp); +#endif + + +#endif // include guard diff --git a/lib/shadow/gshadow/setsgent.c b/lib/shadow/gshadow/setsgent.c new file mode 100644 index 000000000..19028e957 --- /dev/null +++ b/lib/shadow/gshadow/setsgent.c @@ -0,0 +1,29 @@ +// 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 + +#include "shadow/gshadow/setsgent.h" + +#include +#include + +#include "shadow/gshadow/gshadow.h" + + +#if defined(SHADOWGRP) && !__has_include() +void +setsgent(void) +{ + if (NULL != gshadow) { + rewind(gshadow); + } else { + gshadow = fopen(GSHADOW_FILE, "re"); + } +} +#endif diff --git a/lib/shadow/gshadow/setsgent.h b/lib/shadow/gshadow/setsgent.h new file mode 100644 index 000000000..8382f70b2 --- /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 + + +#if __has_include() +# include +#else +void setsgent(void); +#endif + + +#endif // include guard diff --git a/lib/shadow/gshadow/sgetsgent.c b/lib/shadow/gshadow/sgetsgent.c new file mode 100644 index 000000000..5c08d91c6 --- /dev/null +++ b/lib/shadow/gshadow/sgetsgent.c @@ -0,0 +1,100 @@ +// 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 + +#include "shadow/gshadow/sgetsgent.h" + +#include +#include + +#include "alloc/realloc.h" +#include "alloc/x/xmalloc.h" +#include "shadow/gshadow/sgrp.h" +#include "string/strchr/strchrcnt.h" +#include "string/strtok/stpsep.h" + + +#define FIELDS 4 + + +#if defined(SHADOWGRP) && !__has_include() +static struct sgrp sgroup = {}; + + +static char **build_list(char *s); + + +struct sgrp * +sgetsgent(const char *string) +{ + static char *sgrbuf = NULL; + static size_t sgrbuflen = 0; + + char *fields[FIELDS]; + char *cp; + int i; + size_t len = strlen (string) + 1; + + if (len > sgrbuflen) { + char *buf = REALLOC(sgrbuf, len, char); + if (NULL == buf) + return NULL; + + sgrbuf = buf; + sgrbuflen = len; + } + + strcpy (sgrbuf, string); + stpsep(sgrbuf, "\n"); + + /* + * There should be exactly 4 colon separated fields. Find + * all 4 of them and save the starting addresses in fields[]. + */ + + for (cp = sgrbuf, i = 0; (i < FIELDS) && (NULL != cp); i++) + fields[i] = strsep(&cp, ":"); + + /* + * If there was an extra field somehow, or perhaps not enough, + * the line is invalid. + */ + + if (NULL != cp || i != FIELDS) + return NULL; + + sgroup.sg_namp = fields[0]; + sgroup.sg_passwd = fields[1]; + + free(sgroup.sg_adm); + free(sgroup.sg_mem); + + sgroup.sg_adm = build_list(fields[2]); + sgroup.sg_mem = build_list(fields[3]); + + return &sgroup; +} + + +static char ** +build_list(char *s) +{ + char **l; + size_t i; + + l = XMALLOC(strchrcnt(s, ',') + 2, char *); + + for (i = 0; s != NULL && !streq(s, ""); i++) + l[i] = strsep(&s, ","); + + l[i] = NULL; + + return l; +} +#endif diff --git a/lib/shadow/gshadow/sgetsgent.h b/lib/shadow/gshadow/sgetsgent.h new file mode 100644 index 000000000..de7d45b16 --- /dev/null +++ b/lib/shadow/gshadow/sgetsgent.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_SGETSGENT_H_ +#define SHADOW_INCLUDE_LIB_SHADOW_GSHADOW_SGETSGENT_H_ + + +#include + +#include "shadow/gshadow/sgrp.h" + + +#if __has_include() +# include +#else +struct sgrp *sgetsgent(const char *); +#endif + + +#endif // include guard diff --git a/lib/shadow/gshadow/sgrp.c b/lib/shadow/gshadow/sgrp.c new file mode 100644 index 000000000..d34513243 --- /dev/null +++ b/lib/shadow/gshadow/sgrp.c @@ -0,0 +1,11 @@ +// 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 + +#include "shadow/gshadow/sgrp.h" diff --git a/lib/shadow/gshadow/sgrp.h b/lib/shadow/gshadow/sgrp.h new file mode 100644 index 000000000..7f7353131 --- /dev/null +++ b/lib/shadow/gshadow/sgrp.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_SGRP_H_ +#define SHADOW_INCLUDE_LIB_SHADOW_GSHADOW_SGRP_H_ + + +#if __has_include() +# include +#else +struct sgrp { + char *sg_namp; /* group name */ + char *sg_passwd; /* group password */ + char **sg_adm; /* group administrator list */ + char **sg_mem; /* group membership list */ +}; +#endif + + +#endif // include guard diff --git a/lib/sgetpwent.c b/lib/shadow/passwd/sgetpwent.c similarity index 86% rename from lib/sgetpwent.c rename to lib/shadow/passwd/sgetpwent.c index b13d5bc54..38e9d5277 100644 --- a/lib/sgetpwent.c +++ b/lib/shadow/passwd/sgetpwent.c @@ -1,15 +1,14 @@ -/* - * SPDX-FileCopyrightText: 1989 - 1994, Julianne Frances Haugh - * SPDX-FileCopyrightText: 1996 - 1998, Marek Michałkiewicz - * SPDX-FileCopyrightText: 2003 - 2005, Tomasz Kłoczko - * SPDX-FileCopyrightText: 2008 , Nicolas François - * - * SPDX-License-Identifier: BSD-3-Clause - */ +// SPDX-FileCopyrightText: 1989-1994, Julianne Frances Haugh +// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz +// SPDX-FileCopyrightText: 2003-2005, Tomasz Kłoczko +// SPDX-FileCopyrightText: 2008, Nicolas François +// SPDX-FileCopyrightText: 2024, Alejandro Colomar +// SPDX-License-Identifier: BSD-3-Clause + #include -#ident "$Id$" +#include "shadow/passwd/sgetpwent.h" #include #include @@ -25,6 +24,7 @@ #define NFIELDS 7 + /* * sgetpwent - convert a string to a (struct passwd) * @@ -105,4 +105,3 @@ sgetpwent(const char *buf) return &pwent; } - diff --git a/lib/shadow/passwd/sgetpwent.h b/lib/shadow/passwd/sgetpwent.h new file mode 100644 index 000000000..ef432c73f --- /dev/null +++ b/lib/shadow/passwd/sgetpwent.h @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: 2024, Alejandro Colomar +// SPDX-License-Identifier: BSD-3-Clause + + +#ifndef SHADOW_INCLUDE_LIB_SHADOW_PASSWD_SGETPWENT_H_ +#define SHADOW_INCLUDE_LIB_SHADOW_PASSWD_SGETPWENT_H_ + + +#include + +#include + + +struct passwd *sgetpwent(const char *s); + + +#endif // include guard diff --git a/po/POTFILES.in b/po/POTFILES.in index 3aff87b2d..c2f9a4fb9 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 @@ -57,11 +56,11 @@ lib/selinux.c lib/semanage.c lib/setugid.c lib/setupenv.c -lib/sgetgrent.c -lib/sgetpwent.c lib/sgetspent.c lib/sgroupio.c lib/shadow.c +lib/shadow/group/sgetgrent.c +lib/shadow/passwd/sgetpwent.c lib/shadowio.c lib/shadowmem.c lib/shell.c diff --git a/src/chgpasswd.c b/src/chgpasswd.c index c5f302844..46c0f4cbb 100644 --- a/src/chgpasswd.c +++ b/src/chgpasswd.c @@ -34,6 +34,7 @@ #endif /*@-exitarg@*/ #include "exitcodes.h" +#include "shadow/gshadow/sgrp.h" #include "shadowlog.h" #include "string/strcmp/streq.h" #include "string/strtok/stpsep.h" diff --git a/src/gpasswd.c b/src/gpasswd.c index 13abbdab7..d65d5d0b4 100644 --- a/src/gpasswd.c +++ b/src/gpasswd.c @@ -32,6 +32,7 @@ #ifdef SHADOWGRP #include "sgroupio.h" #endif +#include "shadow/gshadow/sgrp.h" #include "shadowlog.h" #include "sssd.h" #include "string/memset/memzero.h" diff --git a/src/groupadd.c b/src/groupadd.c index ab30960e3..12f925014 100644 --- a/src/groupadd.c +++ b/src/groupadd.c @@ -37,6 +37,7 @@ #ifdef SHADOWGRP #include "sgroupio.h" #endif +#include "shadow/gshadow/sgrp.h" #include "shadowlog.h" #include "string/memset/memzero.h" #include "string/strtok/stpsep.h" diff --git a/src/groupmems.c b/src/groupmems.c index d37b237f2..084c937be 100644 --- a/src/groupmems.c +++ b/src/groupmems.c @@ -26,6 +26,7 @@ #ifdef SHADOWGRP #include "sgroupio.h" #endif +#include "shadow/gshadow/sgrp.h" #include "shadowlog.h" #include "string/strcmp/streq.h" #include "string/strdup/xstrdup.h" diff --git a/src/groupmod.c b/src/groupmod.c index 5164c4c3f..c0bc0861a 100644 --- a/src/groupmod.c +++ b/src/groupmod.c @@ -38,6 +38,7 @@ #ifdef SHADOWGRP #include "sgroupio.h" #endif +#include "shadow/gshadow/sgrp.h" #include "shadowlog.h" #include "sssd.h" #include "string/sprintf/stpeprintf.h" diff --git a/src/grpck.c b/src/grpck.c index d3f2baee6..ec8a0266e 100644 --- a/src/grpck.c +++ b/src/grpck.c @@ -22,6 +22,8 @@ #include "groupio.h" #include "nscd.h" #include "prototypes.h" +#include "shadow/gshadow/gshadow.h" +#include "shadow/gshadow/sgrp.h" #include "shadowlog.h" #include "sssd.h" #include "string/strcmp/streq.h" @@ -30,6 +32,7 @@ #include "sgroupio.h" #endif + /* * Exit codes */ @@ -51,7 +54,7 @@ static const char *grp_file = GROUP_FILE; static bool use_system_grp_file = true; #ifdef SHADOWGRP -static const char *sgr_file = SGROUP_FILE; +static const char *sgr_file = GSHADOW_FILE; static bool use_system_sgr_file = true; static bool is_shadow = false; static bool sgr_locked = false; diff --git a/src/grpconv.c b/src/grpconv.c index 1b31cb85a..022defb37 100644 --- a/src/grpconv.c +++ b/src/grpconv.c @@ -36,6 +36,7 @@ #ifdef SHADOWGRP #include "groupio.h" #include "sgroupio.h" +#include "shadow/gshadow/sgrp.h" #include "shadowlog.h" #include "sssd.h" diff --git a/src/grpunconv.c b/src/grpunconv.c index ea65a329f..4a9e821f4 100644 --- a/src/grpunconv.c +++ b/src/grpunconv.c @@ -36,6 +36,8 @@ #ifdef SHADOWGRP #include "groupio.h" #include "sgroupio.h" +#include "shadow/gshadow/gshadow.h" +#include "shadow/gshadow/sgrp.h" #include "shadowlog.h" @@ -201,11 +203,11 @@ int main (int argc, char **argv) fail_exit (3); } - if (unlink (SGROUP_FILE) != 0) { + if (unlink(GSHADOW_FILE) != 0) { fprintf (stderr, _("%s: cannot delete %s\n"), - Prog, SGROUP_FILE); - SYSLOG ((LOG_ERR, "cannot delete %s", SGROUP_FILE)); + Prog, GSHADOW_FILE); + SYSLOG((LOG_ERR, "cannot delete %s", GSHADOW_FILE)); fail_exit (3); } diff --git a/src/login.c b/src/login.c index 2866b1523..322398dc3 100644 --- a/src/login.c +++ b/src/login.c @@ -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" diff --git a/src/newgrp.c b/src/newgrp.c index 6e05277f6..0a982df32 100644 --- a/src/newgrp.c +++ b/src/newgrp.c @@ -27,6 +27,9 @@ #include "search/l/lfind.h" #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" #include "string/strcmp/streq.h" diff --git a/src/newusers.c b/src/newusers.c index e3685efe9..cd10595fd 100644 --- a/src/newusers.c +++ b/src/newusers.c @@ -52,6 +52,7 @@ #ifdef ENABLE_SUBIDS #include "subordinateio.h" #endif /* ENABLE_SUBIDS */ +#include "shadow/gshadow/sgrp.h" #include "shadowlog.h" #include "sssd.h" #include "string/sprintf/snprintf.h" diff --git a/src/useradd.c b/src/useradd.c index 562ba44fc..6289995e1 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -62,6 +62,7 @@ #ifdef WITH_TCB #include "tcbfuncs.h" #endif +#include "shadow/gshadow/sgrp.h" #include "shadowlog.h" #include "sssd.h" #include "string/memset/memzero.h" diff --git a/src/userdel.c b/src/userdel.c index a267ae1d0..edc9bb8a3 100644 --- a/src/userdel.c +++ b/src/userdel.c @@ -50,6 +50,7 @@ #ifdef ENABLE_SUBIDS #include "subordinateio.h" #endif /* ENABLE_SUBIDS */ +#include "shadow/gshadow/sgrp.h" #include "shadowlog.h" #include "string/sprintf/xasprintf.h" #include "string/strcmp/streq.h" diff --git a/src/usermod.c b/src/usermod.c index 7ea1a7244..1aa3a67d1 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -60,6 +60,8 @@ #ifdef WITH_TCB #include "tcbfuncs.h" #endif +#include "shadow/gshadow/endsgent.h" +#include "shadow/gshadow/sgrp.h" #include "shadowlog.h" #include "sssd.h" #include "string/memset/memzero.h"