]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/shadow/, lib/, src/: Use _PATH_GSHADOW from <paths.h>
authorAlejandro Colomar <alx@kernel.org>
Sun, 10 Nov 2024 16:36:44 +0000 (17:36 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Tue, 7 Oct 2025 09:03:09 +0000 (11:03 +0200)
This macro is provided by glibc (but not musl) as _PATH_GSHADOW in
<paths.h>.  Let's use that macro, and define it only if libc doesn't
provide it.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/defines.h
lib/gshadow.c
lib/prefix_flag.c
lib/sgroupio.c
lib/shadow/gshadow/gshadow.h
src/grpck.c
src/grpunconv.c

index 8673a09f4f4e736ab69bc7c5bf5dbc53dabd5ea1..e478552eb1be880bfa5722e87a30b1767ee51c8d 100644 (file)
 #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
index b88bba035354e7c4664ba3f671ca813c1a8fca86..eb2ea5dffb7031eeb06f7100f62a3c0599e57ee4 100644 (file)
@@ -51,7 +51,7 @@ void setsgent (void)
        if (NULL != gshadow) {
                rewind(gshadow);
        } else {
-               gshadow = fopen(SGROUP_FILE, "re");
+               gshadow = fopen(_PATH_GSHADOW, "re");
        }
 }
 
index f69aa106065e0ee2c3d3a79a3f067902c2819a1c..cb807c6ac41852b14d629d30cdb88543b94acd29 100644 (file)
@@ -9,7 +9,9 @@
 
 #ident "$Id$"
 
+#include <paths.h>
 #include <stdio.h>
+
 #include <assert.h>
 
 #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
 
index b6127252bac80ad98626b81d11f9759ee053b492..7c363b083eb4643d315603d1f3cf4f7c445a92b0 100644 (file)
@@ -12,7 +12,7 @@
 
 #ifdef SHADOWGRP
 
-#ident "$Id$"
+#include <paths.h>
 
 #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
index b2a1ef9f55f60c60dbec473063d40fc48257f0c6..42f74823bcfebdd9da6588b937a6edc88a32088d 100644 (file)
 
 #include "config.h"
 
+#include <paths.h>
 #include <stdio.h>
 
 
+#ifndef _PATH_GSHADOW
+# define _PATH_GSHADOW  "/etc/gshadow"
+#endif
+
+
 extern FILE  *gshadow;
 
 
index 51be51cc28abe0450040fdf53de12cdc6190165f..533466cd3f42df116120049ffd71c6a81f324a26 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <fcntl.h>
 #include <grp.h>
+#include <paths.h>
 #include <pwd.h>
 #include <stdio.h>
 #include <getopt.h>
@@ -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;
index f9b24d8127405d47b6729253f73dcc7bb8b7fda6..1f1b45b0c17f35341f0578fd1d5585a841ff63d4 100644 (file)
@@ -14,8 +14,7 @@
 
 #include "config.h"
 
-#ident "$Id$"
-
+#include <paths.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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);
        }