From: Alejandro Colomar Date: Sun, 10 Nov 2024 16:36:44 +0000 (+0100) Subject: lib/shadow/, lib/, src/: Use _PATH_GSHADOW from X-Git-Tag: 4.19.0-rc1~142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a96b90ec8a96bbb7d753f7b202c19884f39d3ba;p=thirdparty%2Fshadow.git lib/shadow/, lib/, src/: Use _PATH_GSHADOW from This macro is provided by glibc (but not musl) as _PATH_GSHADOW in . Let's use that macro, and define it only if libc doesn't provide it. Signed-off-by: Alejandro Colomar --- diff --git a/lib/defines.h b/lib/defines.h index 8673a09f4..e478552eb 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -172,12 +172,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/gshadow.c b/lib/gshadow.c index b88bba035..eb2ea5dff 100644 --- a/lib/gshadow.c +++ b/lib/gshadow.c @@ -51,7 +51,7 @@ void setsgent (void) if (NULL != gshadow) { rewind(gshadow); } else { - gshadow = fopen(SGROUP_FILE, "re"); + gshadow = fopen(_PATH_GSHADOW, "re"); } } diff --git a/lib/prefix_flag.c b/lib/prefix_flag.c index f69aa1060..cb807c6ac 100644 --- a/lib/prefix_flag.c +++ b/lib/prefix_flag.c @@ -9,7 +9,9 @@ #ident "$Id$" +#include #include + #include #include "atoi/getnum.h" @@ -27,6 +29,7 @@ #include "subordinateio.h" #endif /* ENABLE_SUBIDS */ #include "getdef.h" +#include "shadow/gshadow/gshadow.h" #include "shadowlog.h" #include "string/sprintf/xaprintf.h" #include "string/strcmp/streq.h" @@ -115,7 +118,7 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char ** gr_setdbname(group_db_file); #ifdef SHADOWGRP - sgroup_db_file = xaprintf("%s/%s", prefix, SGROUP_FILE); + sgroup_db_file = xaprintf("%s/%s", prefix, _PATH_GSHADOW); sgr_setdbname(sgroup_db_file); #endif diff --git a/lib/sgroupio.c b/lib/sgroupio.c index b6127252b..7c363b083 100644 --- a/lib/sgroupio.c +++ b/lib/sgroupio.c @@ -12,7 +12,7 @@ #ifdef SHADOWGRP -#ident "$Id$" +#include #include "alloc/calloc.h" #include "alloc/malloc.h" @@ -22,6 +22,7 @@ #include "fields.h" #include "getdef.h" #include "sgroupio.h" +#include "shadow/gshadow/gshadow.h" #include "shadow/gshadow/putsgent.h" #include "string/memset/memzero.h" @@ -206,7 +207,7 @@ static struct commonio_ops gshadow_ops = { }; static struct commonio_db gshadow_db = { - SGROUP_FILE, /* filename */ + _PATH_GSHADOW, /* filename */ &gshadow_ops, /* ops */ NULL, /* fp */ #ifdef WITH_SELINUX diff --git a/lib/shadow/gshadow/gshadow.h b/lib/shadow/gshadow/gshadow.h index b2a1ef9f5..42f74823b 100644 --- a/lib/shadow/gshadow/gshadow.h +++ b/lib/shadow/gshadow/gshadow.h @@ -11,9 +11,15 @@ #include "config.h" +#include #include +#ifndef _PATH_GSHADOW +# define _PATH_GSHADOW "/etc/gshadow" +#endif + + extern FILE *gshadow; diff --git a/src/grpck.c b/src/grpck.c index 51be51cc2..533466cd3 100644 --- a/src/grpck.c +++ b/src/grpck.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -22,6 +23,7 @@ #include "groupio.h" #include "nscd.h" #include "prototypes.h" +#include "shadow/gshadow/gshadow.h" #include "shadowlog.h" #include "sssd.h" #include "string/strcmp/streq.h" @@ -31,6 +33,7 @@ #include "sgroupio.h" #endif + /* * Exit codes */ @@ -52,7 +55,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 = _PATH_GSHADOW; static bool use_system_sgr_file = true; static bool is_shadow = false; static bool sgr_locked = false; diff --git a/src/grpunconv.c b/src/grpunconv.c index f9b24d812..1f1b45b0c 100644 --- a/src/grpunconv.c +++ b/src/grpunconv.c @@ -14,8 +14,7 @@ #include "config.h" -#ident "$Id$" - +#include #include #include #include @@ -36,6 +35,7 @@ #ifdef SHADOWGRP #include "groupio.h" #include "sgroupio.h" +#include "shadow/gshadow/gshadow.h" #include "shadowlog.h" @@ -201,11 +201,11 @@ int main (int argc, char **argv) fail_exit (3); } - if (unlink (SGROUP_FILE) != 0) { + if (unlink(_PATH_GSHADOW) != 0) { fprintf (stderr, _("%s: cannot delete %s\n"), - Prog, SGROUP_FILE); - SYSLOG ((LOG_ERR, "cannot delete %s", SGROUP_FILE)); + Prog, _PATH_GSHADOW); + SYSLOG((LOG_ERR, "cannot delete %s", _PATH_GSHADOW)); fail_exit (3); }