[pacman-dev] [PATCH 2/4] Make alpm_db_get_sigverify_level() public
Dan McGee
dan at archlinux.org
Mon Jun 27 17:39:37 EDT 2011
Signed-off-by: Dan McGee <dan at archlinux.org>
---
lib/libalpm/alpm.h | 8 ++++++++
lib/libalpm/be_sync.c | 4 ++--
lib/libalpm/db.c | 11 +++++++++++
lib/libalpm/signing.c | 15 ---------------
lib/libalpm/signing.h | 1 -
lib/libalpm/sync.c | 2 +-
6 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 11ebfc1..ec99541 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -382,6 +382,14 @@ int alpm_db_unregister_all(pmhandle_t *handle);
*/
const char *alpm_db_get_name(const pmdb_t *db);
+/** Get the signature verification level for a database.
+ * Will return the default verification level if this database is set up
+ * with PM_PGP_VERIFY_UNKNOWN.
+ * @param db pointer to the package database
+ * @return the signature verification level
+ */
+pgp_verify_t alpm_db_get_sigverify_level(pmdb_t *db);
+
/** Check the validity of a database.
* This is most useful for sync databases and verifying signature status.
* If invalid, the handle error code will be set accordingly.
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 057891d..bcd8564 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -77,7 +77,7 @@ static int sync_db_validate(pmdb_t *db)
/* this takes into account the default verification level if UNKNOWN
* was assigned to this db */
- check_sig = _alpm_db_get_sigverify_level(db);
+ check_sig = alpm_db_get_sigverify_level(db);
if(check_sig != PM_PGP_VERIFY_NEVER) {
int ret;
@@ -166,7 +166,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
/* make sure we have a sane umask */
oldmask = umask(0022);
- check_sig = _alpm_db_get_sigverify_level(db);
+ check_sig = alpm_db_get_sigverify_level(db);
/* attempt to grab a lock */
if(_alpm_handle_lock(handle)) {
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index a00edcc..ac02740 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -219,6 +219,17 @@ const char SYMEXPORT *alpm_db_get_name(const pmdb_t *db)
return db->treename;
}
+/** Get the signature verification level for a database. */
+pgp_verify_t SYMEXPORT alpm_db_get_sigverify_level(pmdb_t *db)
+{
+ ASSERT(db != NULL, return -1);
+ if(db->pgp_verify == PM_PGP_VERIFY_UNKNOWN) {
+ return alpm_option_get_default_sigverify(db->handle);
+ } else {
+ return db->pgp_verify;
+ }
+}
+
/** Check the validity of a database. */
int SYMEXPORT alpm_db_validity(pmdb_t *db)
{
diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c
index 9826e42..06cb6ac 100644
--- a/lib/libalpm/signing.c
+++ b/lib/libalpm/signing.c
@@ -362,21 +362,6 @@ int _alpm_gpgme_checksig(pmhandle_t *handle, const char *path,
#endif
/**
- * Determines the necessity of checking for a valid PGP signature
- * @param db the sync database to query
- *
- * @return signature verification level
- */
-pgp_verify_t _alpm_db_get_sigverify_level(pmdb_t *db)
-{
- if(db->pgp_verify != PM_PGP_VERIFY_UNKNOWN) {
- return db->pgp_verify;
- } else {
- return alpm_option_get_default_sigverify(db->handle);
- }
-}
-
-/**
* Check the PGP signature for the given package file.
* @param pkg the package to check
* @return a int value : 0 (valid), 1 (invalid), -1 (an error occurred)
diff --git a/lib/libalpm/signing.h b/lib/libalpm/signing.h
index fdf81fc..14b2ad7 100644
--- a/lib/libalpm/signing.h
+++ b/lib/libalpm/signing.h
@@ -23,7 +23,6 @@
int _alpm_gpgme_checksig(pmhandle_t *handle, const char *path,
const char *base64_sig);
-pgp_verify_t _alpm_db_get_sigverify_level(pmdb_t *db);
#endif /* _ALPM_SIGNING_H */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 15f135b..0a38a77 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -874,7 +874,7 @@ int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data)
filename = alpm_pkg_get_filename(spkg);
filepath = _alpm_filecache_find(handle, filename);
pmdb_t *sdb = alpm_pkg_get_db(spkg);
- check_sig = _alpm_db_get_sigverify_level(sdb);
+ check_sig = alpm_db_get_sigverify_level(sdb);
/* load the package file and replace pkgcache entry with it in the target list */
/* TODO: alpm_pkg_get_db() will not work on this target anymore */
--
1.7.5.4
More information about the pacman-dev
mailing list