[pacman-dev] [PATCH 4/5] be_package: lookup missing keys in the WKD using the packager email

Jonas Witschel diabonas at gmx.de
Wed Jul 17 20:06:52 UTC 2019


In contrast to the preceeding commit we do not have a database with the
required packager information to work with, so we need to extract the
package temporarily to obtain this information.

Signed-off-by: Jonas Witschel <diabonas at gmx.de>
---
 lib/libalpm/be_package.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index fbb0d43e..28f04371 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -731,6 +731,8 @@ int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int ful
 {
 	int validation = 0;
 	char *sigpath;
+	alpm_pkg_t *pkg_temp;
+	char *email;

 	CHECK_HANDLE(handle, return -1);
 	ASSERT(pkg != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
@@ -755,9 +757,17 @@ int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int ful
 				for(k = keys; k; k = k->next) {
 					char *key = k->data;
 					if(_alpm_key_in_keychain(handle, key) == 0) {
-						if(_alpm_key_import(handle, NULL, key) == -1) {
+						pkg_temp = _alpm_pkg_load_internal(handle, filename, full);
+						if(pkg_temp) {
+							_alpm_email_from_uid(pkg_temp->packager, &email);
+							_alpm_pkg_free(pkg_temp);
+						} else {
+							email = NULL;
+						}
+						if(_alpm_key_import(handle, email, key) == -1) {
 							fail = 1;
 						}
+						free(email);
 					}
 				}
 				FREELIST(keys);
--
2.22.0


More information about the pacman-dev mailing list