On 28/10/13 23:58, Andrew Gregory wrote:
Both repo-specific siglevels and file siglevels used the default siglevel as their base. Previously, repo siglevels inherited when the repo was parsed, but file siglevels inherited after config parsing was complete. Having both options inherit from the default when they are first parsed is more intuitive and reduces parser complexity.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> ---
This may change how some existing config files are parsed, but I doubt anybody is purposefully using the old behavior.
Can you provide details of the old behaviour that is "broken" by this?
lib/libalpm/alpm.h | 3 --- lib/libalpm/be_sync.c | 2 +- src/pacman/conf.c | 36 ++++++------------------------------ 3 files changed, 7 insertions(+), 34 deletions(-)
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index b049007..034b155 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -115,9 +115,6 @@ typedef enum _alpm_siglevel_t { ALPM_SIG_DATABASE_MARGINAL_OK = (1 << 12), ALPM_SIG_DATABASE_UNKNOWN_OK = (1 << 13),
- ALPM_SIG_PACKAGE_SET = (1 << 27), - ALPM_SIG_PACKAGE_TRUST_SET = (1 << 28), - ALPM_SIG_USE_DEFAULT = (1 << 31) } alpm_siglevel_t;
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 123d953..a4d6aff 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -694,7 +694,7 @@ alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename, _alpm_log(handle, ALPM_LOG_DEBUG, "registering sync database '%s'\n", treename);
#ifndef HAVE_LIBGPGME - if((level &= ~ALPM_SIG_PACKAGE_SET) != 0 && level != ALPM_SIG_USE_DEFAULT) { + if(level != 0 && level != ALPM_SIG_USE_DEFAULT) { RET_ERR(handle, ALPM_ERR_WRONG_ARGS, NULL); } #endif diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 231fe2a..387ade4 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -328,7 +328,6 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage, if(strcmp(value, "Never") == 0) { if(package) { level &= ~ALPM_SIG_PACKAGE; - level |= ALPM_SIG_PACKAGE_SET; } if(database) { level &= ~ALPM_SIG_DATABASE; @@ -337,7 +336,6 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage, if(package) { level |= ALPM_SIG_PACKAGE; level |= ALPM_SIG_PACKAGE_OPTIONAL; - level |= ALPM_SIG_PACKAGE_SET; } if(database) { level |= ALPM_SIG_DATABASE; @@ -347,7 +345,6 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage, if(package) { level |= ALPM_SIG_PACKAGE; level &= ~ALPM_SIG_PACKAGE_OPTIONAL; - level |= ALPM_SIG_PACKAGE_SET; } if(database) { level |= ALPM_SIG_DATABASE; @@ -357,7 +354,6 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage, if(package) { level &= ~ALPM_SIG_PACKAGE_MARGINAL_OK; level &= ~ALPM_SIG_PACKAGE_UNKNOWN_OK; - level |= ALPM_SIG_PACKAGE_TRUST_SET; } if(database) { level &= ~ALPM_SIG_DATABASE_MARGINAL_OK; @@ -367,7 +363,6 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage, if(package) { level |= ALPM_SIG_PACKAGE_MARGINAL_OK; level |= ALPM_SIG_PACKAGE_UNKNOWN_OK; - level |= ALPM_SIG_PACKAGE_TRUST_SET; } if(database) { level |= ALPM_SIG_DATABASE_MARGINAL_OK; @@ -397,28 +392,6 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage, return ret; }
-/** - * Merge the package entires of two signature verification levels. - * @param base initial siglevel - * @param over overridden siglevel, derived value is stored here - */ -static void merge_siglevel(alpm_siglevel_t *base, alpm_siglevel_t *over) -{ - alpm_siglevel_t level = *over; - if(!(level & ALPM_SIG_USE_DEFAULT)) { - if(!(level & ALPM_SIG_PACKAGE_SET)) { - level |= *base & ALPM_SIG_PACKAGE; - level |= *base & ALPM_SIG_PACKAGE_OPTIONAL; - } - if(!(level & ALPM_SIG_PACKAGE_TRUST_SET)) { - level |= *base & ALPM_SIG_PACKAGE_MARGINAL_OK; - level |= *base & ALPM_SIG_PACKAGE_UNKNOWN_OK; - } - } - - *over = level; -} - static int process_cleanmethods(alpm_list_t *values, const char *file, int linenum) { @@ -572,6 +545,9 @@ static int _parse_options(const char *key, char *value, FREELIST(values); } else if(strcmp(key, "LocalFileSigLevel") == 0) { alpm_list_t *values = NULL; + if(config->localfilesiglevel == ALPM_SIG_USE_DEFAULT) { + config->localfilesiglevel = config->siglevel; + } setrepeatingoption(value, "LocalFileSigLevel", &values); if(process_siglevel(values, &config->localfilesiglevel, file, linenum)) { FREELIST(values); @@ -580,6 +556,9 @@ static int _parse_options(const char *key, char *value, FREELIST(values); } else if(strcmp(key, "RemoteFileSigLevel") == 0) { alpm_list_t *values = NULL; + if(config->remotefilesiglevel == ALPM_SIG_USE_DEFAULT) { + config->remotefilesiglevel = config->siglevel; + } setrepeatingoption(value, "RemoteFileSigLevel", &values); if(process_siglevel(values, &config->remotefilesiglevel, file, linenum)) { FREELIST(values); @@ -707,9 +686,6 @@ static int setup_libalpm(void) }
alpm_option_set_default_siglevel(handle, config->siglevel); - - merge_siglevel(&config->siglevel, &config->localfilesiglevel); - merge_siglevel(&config->siglevel, &config->remotefilesiglevel); alpm_option_set_local_file_siglevel(handle, config->localfilesiglevel); alpm_option_set_remote_file_siglevel(handle, config->remotefilesiglevel);