From: Michael Tremer Date: Wed, 29 Nov 2017 17:15:22 +0000 (+0100) Subject: key: Ensure that GPG database directory exists X-Git-Tag: 0.9.28~1285^2~1248 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bec97e1b2a0c9dd9dad1a019ffe838c0a11fe0d;p=pakfire.git key: Ensure that GPG database directory exists Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/key.c b/src/libpakfire/key.c index f38b6332e..819b8d2c7 100644 --- a/src/libpakfire/key.c +++ b/src/libpakfire/key.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #include @@ -50,6 +52,19 @@ gpgme_ctx_t pakfire_get_gpgctx(Pakfire pakfire) { // Use GPG const char* path = pakfire_get_path(pakfire); char* home = pakfire_path_join(path, "etc/pakfire/gnupg"); + + // Check if gpg directories exist + if (pakfire_access(home, NULL, R_OK) != 0) { + DEBUG("Creating GPG database at %s\n", home); + + int r = pakfire_mkdir(home, S_IRUSR|S_IWUSR|S_IXUSR); + if (r) { + ERROR("Could not initialize the GPG database at %s\n", home); + return NULL; + } + } + + // Setup engine error = gpgme_set_engine_info(GPGME_PROTOCOL_OpenPGP, NULL, home); pakfire_free(home); if (gpg_err_code(error) != GPG_ERR_NO_ERROR)