]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Define SUBUID_FILE/SUBGID_FILE
authorJoakim Tjernlund <joakim.tjernlund@infinera.com>
Wed, 1 Nov 2023 23:00:03 +0000 (00:00 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Mon, 13 Nov 2023 11:40:48 +0000 (12:40 +0100)
These where hard coded, make them definable like SHADOW_FILE

Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
lib/defines.h
lib/prefix_flag.c
lib/subordinateio.c

index 3a280b3eaf14c1f3cfcfcfbb3a6ef1917974e755..66b70b63febfd6090158f4ca7d421cc8cdf5f45e 100644 (file)
 #define SHADOW_FILE "/etc/shadow"
 #endif
 
+#ifndef SUBUID_FILE
+#define SUBUID_FILE "/etc/subuid"
+#endif
+
+#ifndef SUBGID_FILE
+#define SUBGID_FILE "/etc/subgid"
+#endif
+
 #ifdef SHADOWGRP
 #ifndef SGROUP_FILE
 #define SGROUP_FILE "/etc/gshadow"
index 80793d0ed096fb3c72733a37b35a118c60c58c92..9d766818aa1b7595c04857e6360801289e4689e0 100644 (file)
@@ -125,10 +125,10 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char **
                spw_setdbname(spw_db_file);
 
 #ifdef ENABLE_SUBIDS
-               xasprintf(&suid_db_file, "%s/%s", prefix, "/etc/subuid");
+               xasprintf(&suid_db_file, "%s/%s", prefix, SUBUID_FILE);
                sub_uid_setdbname(suid_db_file);
 
-               xasprintf(&sgid_db_file, "%s/%s", prefix, "/etc/subgid");
+               xasprintf(&sgid_db_file, "%s/%s", prefix, SUBGID_FILE);
                sub_gid_setdbname(sgid_db_file);
 #endif
 
index 31470c84645d4edc00c3988fe43dd6842b038a0e..5c5c00beaafcd46a2d0a91fbf51d13366941f0c8 100644 (file)
@@ -210,7 +210,7 @@ static const struct subordinate_range *find_range(struct commonio_db *db,
         /*
          * We only do special handling for these two files
          */
-        if ((0 != strcmp(db->filename, "/etc/subuid")) && (0 != strcmp(db->filename, "/etc/subgid")))
+        if ((0 != strcmp(db->filename, SUBUID_FILE)) && (0 != strcmp(db->filename, SUBGID_FILE)))
                 return NULL;
 
         /*
@@ -562,7 +562,7 @@ static int remove_range (struct commonio_db *db,
 }
 
 static struct commonio_db subordinate_uid_db = {
-       "/etc/subuid",          /* filename */
+       SUBUID_FILE,            /* filename */
        &subordinate_ops,       /* ops */
        NULL,                   /* fp */
 #ifdef WITH_SELINUX
@@ -669,7 +669,7 @@ uid_t sub_uid_find_free_range(uid_t min, uid_t max, unsigned long count)
 }
 
 static struct commonio_db subordinate_gid_db = {
-       "/etc/subgid",          /* filename */
+       SUBGID_FILE,            /* filename */
        &subordinate_ops,       /* ops */
        NULL,                   /* fp */
 #ifdef WITH_SELINUX