[pacman-dev] [PATCH] check if keyring is readable
If we can't read the keyring, gpgme will output confusing debug information and fail to verify the signature, so we should warn the user before. Signed-off-by: Florian Pritz <bluewind@xinu.at> --- lib/libalpm/signing.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c index 1ac9963..19d3454 100644 --- a/lib/libalpm/signing.c +++ b/lib/libalpm/signing.c @@ -110,6 +110,8 @@ static int init_gpgme(alpm_handle_t *handle) const char *version, *sigdir; gpgme_error_t err; gpgme_engine_info_t enginfo; + const char *needed_files[] = {"secring.gpg", "trustdb.gpg", "gpg.conf", NULL}; + int i = 0; if(init) { /* we already successfully initialized the library */ @@ -121,6 +123,21 @@ static int init_gpgme(alpm_handle_t *handle) RET_ERR(handle, ALPM_ERR_SIG_MISSINGDIR, 1); } + i = 0; + while (needed_files[i] != NULL) { + char *check_path = NULL; + size_t len = strlen(sigdir) + strlen(needed_files[i]) + 1; + + CALLOC(check_path, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, -1)); + snprintf(check_path, len, "%s%s", sigdir, needed_files[i]); + + if(access(check_path, R_OK) != 0) { + _alpm_log(handle, ALPM_LOG_WARNING, _("\"%s\" not readable. Signature verification will likely fail!\n"), check_path); + } + i++; + } + + /* calling gpgme_check_version() returns the current version and runs * some internal library setup code */ version = gpgme_check_version(NULL); -- 1.7.6
participants (1)
-
Florian Pritz