index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | lib/libalpm/alpm.h | 3 | ||||
-rw-r--r-- | lib/libalpm/be_sync.c | 2 | ||||
-rw-r--r-- | src/pacman/conf.c | 90 | ||||
-rw-r--r-- | src/pacman/conf.h | 5 |
@@ -565,6 +565,9 @@ API CHANGES BETWEEN 4.1 AND 4.2 API CHANGES BETWEEN 4.2 AND 5.0 =============================== +[REMOVED] +- alpm_siglevel_t - removed members ALPM_SIG_PACKAGE_SET, ALPM_SIG_PACKAGE_TRUST_SET + [ADDED] - pkgbase accessor - alpm_pkg_get_base() diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 91b94615..53793b4b 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -202,9 +202,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 6e89ad93..0c4519aa 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -709,7 +709,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 != 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 085e7569..a2126e3f 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -318,12 +318,15 @@ int config_set_arch(const char *arch) * @return 0 on success, 1 on any parsing error */ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage, - const char *file, int linenum) + alpm_siglevel_t *storage_mask, const char *file, int linenum) { - alpm_siglevel_t level = *storage; + alpm_siglevel_t level = *storage, mask = *storage_mask; alpm_list_t *i; int ret = 0; +#define SLSET(sl) do { level |= (sl); mask |= (sl); } while(0) +#define SLUNSET(sl) do { level &= ~(sl); mask |= (sl); } while(0) + /* Collapse the option names into a single bitmasked value */ for(i = values; i; i = alpm_list_next(i)) { const char *original = i->data, *value; @@ -346,51 +349,40 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage, /* now parse out and store actual flag if it is valid */ if(strcmp(value, "Never") == 0) { if(package) { - level &= ~ALPM_SIG_PACKAGE; - level |= ALPM_SIG_PACKAGE_SET; + SLUNSET(ALPM_SIG_PACKAGE); } if(database) { - level &= ~ALPM_SIG_DATABASE; + SLUNSET(ALPM_SIG_DATABASE); } } else if(strcmp(value, "Optional") == 0) { if(package) { - level |= ALPM_SIG_PACKAGE; - level |= ALPM_SIG_PACKAGE_OPTIONAL; - level |= ALPM_SIG_PACKAGE_SET; + SLSET(ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL); } if(database) { - level |= ALPM_SIG_DATABASE; - level |= ALPM_SIG_DATABASE_OPTIONAL; + SLSET(ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL); } } else if(strcmp(value, "Required") == 0) { if(package) { - level |= ALPM_SIG_PACKAGE; - level &= ~ALPM_SIG_PACKAGE_OPTIONAL; - level |= ALPM_SIG_PACKAGE_SET; + SLSET(ALPM_SIG_PACKAGE); + SLUNSET(ALPM_SIG_PACKAGE_OPTIONAL); } if(database) { - level |= ALPM_SIG_DATABASE; - level &= ~ALPM_SIG_DATABASE_OPTIONAL; + SLSET(ALPM_SIG_DATABASE); + SLUNSET(ALPM_SIG_DATABASE_OPTIONAL); } } else if(strcmp(value, "TrustedOnly") == 0) { if(package) { - level &= ~ALPM_SIG_PACKAGE_MARGINAL_OK; - level &= ~ALPM_SIG_PACKAGE_UNKNOWN_OK; - level |= ALPM_SIG_PACKAGE_TRUST_SET; + SLUNSET(ALPM_SIG_PACKAGE_MARGINAL_OK | ALPM_SIG_PACKAGE_UNKNOWN_OK); } if(database) { - level &= ~ALPM_SIG_DATABASE_MARGINAL_OK; - level &= ~ALPM_SIG_DATABASE_UNKNOWN_OK; + SLUNSET(ALPM_SIG_DATABASE_MARGINAL_OK | ALPM_SIG_DATABASE_UNKNOWN_OK); } } else if(strcmp(value, "TrustAll") == 0) { if(package) { - level |= ALPM_SIG_PACKAGE_MARGINAL_OK; - level |= ALPM_SIG_PACKAGE_UNKNOWN_OK; - level |= ALPM_SIG_PACKAGE_TRUST_SET; + SLSET(ALPM_SIG_PACKAGE_MARGINAL_OK | ALPM_SIG_PACKAGE_UNKNOWN_OK); } if(database) { - level |= ALPM_SIG_DATABASE_MARGINAL_OK; - level |= ALPM_SIG_DATABASE_UNKNOWN_OK; + SLSET(ALPM_SIG_DATABASE_MARGINAL_OK | ALPM_SIG_DATABASE_UNKNOWN_OK); } } else { pm_printf(ALPM_LOG_ERROR, @@ -401,6 +393,9 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage, level &= ~ALPM_SIG_USE_DEFAULT; } +#undef SLSET +#undef SLUNSET + /* ensure we have sig checking ability and are actually turning it on */ if(!(alpm_capabilities() & ALPM_CAPABILITY_SIGNATURES) && level & (ALPM_SIG_PACKAGE | ALPM_SIG_DATABASE)) { @@ -412,6 +407,7 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage, if(!ret) { *storage = level; + *storage_mask = mask; } return ret; } @@ -419,23 +415,13 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage, /** * Merge the package entires of two signature verification levels. * @param base initial siglevel - * @param over overridden siglevel, derived value is stored here + * @param over overridden siglevel + * @return merged siglevel */ -static void merge_siglevel(alpm_siglevel_t *base, alpm_siglevel_t *over) +static alpm_siglevel_t merge_siglevel(alpm_siglevel_t base, + alpm_siglevel_t over, alpm_siglevel_t mask) { - 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; + return mask ? (over & mask) | (base & ~mask) : over; } static int process_cleanmethods(alpm_list_t *values, @@ -584,7 +570,8 @@ static int _parse_options(const char *key, char *value, } else if(strcmp(key, "SigLevel") == 0) { alpm_list_t *values = NULL; setrepeatingoption(value, "SigLevel", &values); - if(process_siglevel(values, &config->siglevel, file, linenum)) { + if(process_siglevel(values, &config->siglevel, + &config->siglevel_mask, file, linenum)) { FREELIST(values); return 1; } @@ -592,7 +579,8 @@ static int _parse_options(const char *key, char *value, } else if(strcmp(key, "LocalFileSigLevel") == 0) { alpm_list_t *values = NULL; setrepeatingoption(value, "LocalFileSigLevel", &values); - if(process_siglevel(values, &config->localfilesiglevel, file, linenum)) { + if(process_siglevel(values, &config->localfilesiglevel, + &config->localfilesiglevel_mask, file, linenum)) { FREELIST(values); return 1; } @@ -600,7 +588,8 @@ static int _parse_options(const char *key, char *value, } else if(strcmp(key, "RemoteFileSigLevel") == 0) { alpm_list_t *values = NULL; setrepeatingoption(value, "RemoteFileSigLevel", &values); - if(process_siglevel(values, &config->remotefilesiglevel, file, linenum)) { + if(process_siglevel(values, &config->remotefilesiglevel, + &config->remotefilesiglevel_mask, file, linenum)) { FREELIST(values); return 1; } @@ -728,8 +717,11 @@ 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); + config->localfilesiglevel = merge_siglevel(config->siglevel, + config->localfilesiglevel, config->localfilesiglevel_mask); + config->remotefilesiglevel = merge_siglevel(config->siglevel, + config->remotefilesiglevel, config->remotefilesiglevel_mask); + alpm_option_set_local_file_siglevel(handle, config->localfilesiglevel); alpm_option_set_remote_file_siglevel(handle, config->remotefilesiglevel); @@ -839,10 +831,8 @@ static int _parse_repo(const char *key, char *value, const char *file, alpm_list_t *values = NULL; setrepeatingoption(value, "SigLevel", &values); if(values) { - if(repo->siglevel == ALPM_SIG_USE_DEFAULT) { - repo->siglevel = config->siglevel; - } - ret = process_siglevel(values, &repo->siglevel, file, line); + ret = process_siglevel(values, &repo->siglevel, + &repo->siglevel_mask, file, line); FREELIST(values); } } @@ -888,6 +878,8 @@ static int finish_section(struct section_t *section) } /* if we are not looking at options sections only, register a db */ + repo->siglevel = merge_siglevel(config->siglevel, + repo->siglevel, repo->siglevel_mask); db = alpm_register_syncdb(config->handle, section->name, repo->siglevel); if(db == NULL) { pm_printf(ALPM_LOG_ERROR, _("could not register '%s' database (%s)\n"), diff --git a/src/pacman/conf.h b/src/pacman/conf.h index e1d13379..3eae363f 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -38,6 +38,7 @@ typedef struct __config_repo_t { alpm_list_t *servers; alpm_db_usage_t usage; alpm_siglevel_t siglevel; + alpm_siglevel_t siglevel_mask; } config_repo_t; typedef struct __config_t { @@ -94,6 +95,10 @@ typedef struct __config_t { alpm_siglevel_t localfilesiglevel; alpm_siglevel_t remotefilesiglevel; + alpm_siglevel_t siglevel_mask; + alpm_siglevel_t localfilesiglevel_mask; + alpm_siglevel_t remotefilesiglevel_mask; + /* conf file options */ /* I Love Candy! */ unsigned short chomp; |