Define SUBUID_FILE/SUBGID_FILE

These where hard coded, make them definable like SHADOW_FILE

Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
This commit is contained in:
Joakim Tjernlund 2023-11-02 00:00:03 +01:00 committed by Iker Pedrosa
parent a9e642d444
commit ee3a79c695
3 changed files with 13 additions and 5 deletions

View File

@ -167,6 +167,14 @@
#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"

View 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

View 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