conf: do not default sysroot to /

Setting sysroot to / is not the same as having no sysroot, because the
sysroot is prepended to ALL config paths including relative ones:

$ cd /etc
$ pacman --config=pacman.conf
error: config file /pacman.conf could not be read: No such file or directory

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
This commit is contained in:
Andrew Gregory 2024-02-29 00:05:11 -08:00 committed by Allan McRae
parent cddad6fccd
commit 9f6c081771

View file

@ -108,7 +108,6 @@ config_t *config_new(void)
newconfig->op = PM_OP_MAIN; newconfig->op = PM_OP_MAIN;
newconfig->logmask = ALPM_LOG_ERROR | ALPM_LOG_WARNING; newconfig->logmask = ALPM_LOG_ERROR | ALPM_LOG_WARNING;
newconfig->configfile = strdup(CONFFILE); newconfig->configfile = strdup(CONFFILE);
newconfig->sysroot = strdup("/");
if(alpm_capabilities() & ALPM_CAPABILITY_SIGNATURES) { if(alpm_capabilities() & ALPM_CAPABILITY_SIGNATURES) {
newconfig->siglevel = ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL | newconfig->siglevel = ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL |
ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL; ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL;
@ -1257,8 +1256,7 @@ static int prepend_sysroot(config_t *c)
{ {
alpm_list_t *i; alpm_list_t *i;
if(c->sysroot == NULL || c->sysroot[0] == '\0' if(c->sysroot == NULL) {
|| strcmp(c->sysroot, "/") == 0) {
return 0; return 0;
} }