From db3b86e7f34f4c3ccb42e98465f2069aa642a85f Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 7 Jun 2011 17:29:55 -0500 Subject: Do database signature checking at load time This is the ideal place to do it as all clients should be checking the return value and ensuring there are no errors. This is similar to pkg_load(). We also add an additional step of validation after we download a new database; a subsequent '-y' operation can potentially invalidate the original check at registration time. Note that this implementation is still a bit naive; if a signature is invalid it is currently impossible to refresh and re-download the file without manually deleting it first. Similarly, if one downloads a database and the check fails, the database object is still there and can be used. These shortcomings will be addressed in a future commit. Signed-off-by: Dan McGee --- src/util/cleanupdelta.c | 2 +- src/util/testdb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/util') diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c index 98291706..5ee59dbb 100644 --- a/src/util/cleanupdelta.c +++ b/src/util/cleanupdelta.c @@ -75,7 +75,7 @@ static void checkdbs(const char *dbpath, alpm_list_t *dbnames) { for(i = dbnames; i; i = alpm_list_next(i)) { char *dbname = alpm_list_getdata(i); snprintf(syncdbpath, PATH_MAX, "%s/sync/%s", dbpath, dbname); - db = alpm_db_register_sync(handle, dbname); + db = alpm_db_register_sync(handle, dbname, PM_PGP_VERIFY_OPTIONAL); if(db == NULL) { fprintf(stderr, "error: could not register sync database (%s)\n", alpm_strerror(alpm_errno(handle))); diff --git a/src/util/testdb.c b/src/util/testdb.c index 4937480d..af5007e2 100644 --- a/src/util/testdb.c +++ b/src/util/testdb.c @@ -151,7 +151,7 @@ static int check_syncdbs(alpm_list_t *dbnames) { for(i = dbnames; i; i = alpm_list_next(i)) { char *dbname = alpm_list_getdata(i); - db = alpm_db_register_sync(handle, dbname); + db = alpm_db_register_sync(handle, dbname, PM_PGP_VERIFY_OPTIONAL); if(db == NULL) { fprintf(stderr, "error: could not register sync database (%s)\n", alpm_strerror(alpm_errno(handle))); -- cgit v1.2.3-54-g00ecf From e06586ceb49a0dc7e59996ae3a1483337d2ada05 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Tue, 21 Jun 2011 13:42:17 -0400 Subject: pactree: carry a list of databases for dep resolution Declare an alpm_list which, for now, only holds our local database. walk_deps and walk_reverse_deps are refactored to account for this, and a helper function is added to wrap alpm_db_get_pkg for traversing a list. This is groundwork for letting pactree walk the sync DBs. Signed-off-by: Dave Reisner Signed-off-by: Dan McGee --- src/util/pactree.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'src/util') diff --git a/src/util/pactree.c b/src/util/pactree.c index 6b29d935..87bac6d1 100644 --- a/src/util/pactree.c +++ b/src/util/pactree.c @@ -75,7 +75,6 @@ static struct color_choices no_color = { /* globals */ pmhandle_t *handle = NULL; -pmdb_t *db_local; alpm_list_t *walked = NULL; alpm_list_t *provisions = NULL; @@ -241,15 +240,27 @@ static void print_end(void) } } +static pmpkg_t *get_pkg_from_dbs(alpm_list_t *dbs, const char *needle) { + alpm_list_t *i; + pmpkg_t *ret; + + for(i = dbs; i; i = alpm_list_next(i)) { + ret = alpm_db_get_pkg(alpm_list_getdata(i), needle); + if(ret) { + return ret; + } + } + return NULL; +} /** * walk dependencies in reverse, showing packages which require the target */ -static void walk_reverse_deps(pmpkg_t *pkg, int depth) +static void walk_reverse_deps(alpm_list_t *dblist, pmpkg_t *pkg, int depth) { alpm_list_t *required_by, *i; - if((max_depth >= 0) && (depth == max_depth + 1)) { + if(!pkg || ((max_depth >= 0) && (depth == max_depth + 1))) { return; } @@ -267,7 +278,7 @@ static void walk_reverse_deps(pmpkg_t *pkg, int depth) } } else { print(alpm_pkg_get_name(pkg), pkgname, NULL, depth); - walk_reverse_deps(alpm_db_get_pkg(db_local, pkgname), depth + 1); + walk_reverse_deps(dblist, get_pkg_from_dbs(dblist, pkgname), depth + 1); } } @@ -277,7 +288,7 @@ static void walk_reverse_deps(pmpkg_t *pkg, int depth) /** * walk dependencies, showing dependencies of the target */ -static void walk_deps(pmpkg_t *pkg, int depth) +static void walk_deps(alpm_list_t *dblist, pmpkg_t *pkg, int depth) { alpm_list_t *i; @@ -289,8 +300,7 @@ static void walk_deps(pmpkg_t *pkg, int depth) for(i = alpm_pkg_get_depends(pkg); i; i = alpm_list_next(i)) { pmdepend_t *depend = alpm_list_getdata(i); - pmpkg_t *provider = alpm_find_satisfier(alpm_db_get_pkgcache(db_local), - depend->name); + pmpkg_t *provider = alpm_find_dbs_satisfier(handle, dblist, depend->name); if(provider) { const char *provname = alpm_pkg_get_name(provider); @@ -303,7 +313,7 @@ static void walk_deps(pmpkg_t *pkg, int depth) } } else { print(alpm_pkg_get_name(pkg), provname, depend->name, depth); - walk_deps(provider, depth + 1); + walk_deps(dblist, provider, depth + 1); } } else { /* unresolvable package */ @@ -318,6 +328,7 @@ int main(int argc, char *argv[]) enum _pmerrno_t err; const char *target_name; pmpkg_t *pkg; + alpm_list_t *dblist = NULL; if(parse_options(argc, argv) != 0) { usage(); @@ -333,12 +344,12 @@ int main(int argc, char *argv[]) goto finish; } - db_local = alpm_option_get_localdb(handle); + dblist = alpm_list_add(dblist, alpm_option_get_localdb(handle)); /* we only care about the first non option arg for walking */ target_name = argv[optind]; - pkg = alpm_find_satisfier(alpm_db_get_pkgcache(db_local), target_name); + pkg = alpm_find_dbs_satisfier(handle, dblist, target_name); if(!pkg) { fprintf(stderr, "error: package '%s' not found\n", target_name); ret = 1; @@ -348,13 +359,15 @@ int main(int argc, char *argv[]) print_start(alpm_pkg_get_name(pkg), target_name); if(reverse) { - walk_reverse_deps(pkg, 1); + walk_reverse_deps(dblist, pkg, 1); } else { - walk_deps(pkg, 1); + walk_deps(dblist, pkg, 1); } print_end(); + alpm_list_free(dblist); + finish: cleanup(); return ret; -- cgit v1.2.3-54-g00ecf