Add support for a vendor directory and libeconf

With this, it is possible for Linux distributors to store their
supplied default configuration files somewhere below /usr, while
/etc only contains the changes made by the user. The new option
--enable-vendordir defines where the shadow suite should additional
look for login.defs if this file is not in /etc.
libeconf is a key/value configuration file reading library, which
handles the split of configuration files in different locations
and merges them transparently for the application.
This commit is contained in:
Thorsten Kukuk
2019-09-20 10:27:31 +02:00
committed by Serge Hallyn
parent a74587a4ea
commit b52ce71c27
6 changed files with 132 additions and 36 deletions

View File

@ -96,7 +96,7 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char **
}
}
if (prefix != NULL) {
if ( prefix[0] == '\0' || !strcmp(prefix, "/"))
@ -113,7 +113,7 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char **
group_db_file = xmalloc(len);
snprintf(group_db_file, len, "%s/%s", prefix, GROUP_FILE);
gr_setdbname(group_db_file);
#ifdef SHADOWGRP
len = strlen(prefix) + strlen(SGROUP_FILE) + 2;
sgroup_db_file = xmalloc(len);
@ -128,7 +128,7 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char **
spw_db_file = xmalloc(len);
snprintf(spw_db_file, len, "%s/%s", prefix, SHADOW_FILE);
spw_setdbname(spw_db_file);
#ifdef ENABLE_SUBIDS
len = strlen(prefix) + strlen("/etc/subuid") + 2;
suid_db_file = xmalloc(len);
@ -141,11 +141,15 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char **
sub_gid_setdbname(sgid_db_file);
#endif
#ifdef USE_ECONF
setdef_config_file(prefix);
#else
len = strlen(prefix) + strlen("/etc/login.defs") + 2;
def_conf_file = xmalloc(len);
snprintf(def_conf_file, len, "%s/%s", prefix, "/etc/login.defs");
setdef_config_file(def_conf_file);
}
#endif
}
if (prefix == NULL)
return "";
@ -169,7 +173,7 @@ extern struct group *prefix_getgrnam(const char *name)
fclose(fg);
return grp;
}
return getgrnam(name);
}
@ -262,7 +266,7 @@ extern void prefix_setpwent()
}
if (fp_pwent)
fclose (fp_pwent);
fp_pwent = fopen(passwd_db_file, "rt");
if(!fp_pwent)
return;
@ -293,7 +297,7 @@ extern void prefix_setgrent()
}
if (fp_grent)
fclose (fp_grent);
fp_grent = fopen(group_db_file, "rt");
if(!fp_grent)
return;