comparison mcabber/mcabber/pgp.c @ 2233:90c25a29fb35

New option: 'gpg_path' The path to the gpg binary can now be specified in order to force the use of GnuPG version 1 on systems which have both versions installed.
author Holger Weiß <holger@zedat.fu-berlin.de>
date Sat, 21 Nov 2015 17:44:55 +0100
parents 778280b01bcb
children 232c26383fc4
comparison
equal deleted inserted replaced
2232:c06488852cdc 2233:90c25a29fb35
30 #include <locale.h> 30 #include <locale.h>
31 #include <sys/mman.h> 31 #include <sys/mman.h>
32 #include <glib.h> 32 #include <glib.h>
33 33
34 #include "pgp.h" 34 #include "pgp.h"
35 #include "settings.h"
35 #include "logprint.h" 36 #include "logprint.h"
36 37
37 #define MIN_GPGME_VERSION "1.0.0" 38 #define MIN_GPGME_VERSION "1.1.0"
38 39
39 static struct gpg_struct 40 static struct gpg_struct
40 { 41 {
41 int enabled; 42 int enabled;
42 int version1; 43 int version1;
54 { 55 {
55 gpgme_error_t err; 56 gpgme_error_t err;
56 57
57 gpgme_ctx_t ctx; 58 gpgme_ctx_t ctx;
58 gpgme_engine_info_t info; 59 gpgme_engine_info_t info;
60 const char *gpg_path;
59 61
60 // Check for version and OpenPGP protocol support. 62 // Check for version and OpenPGP protocol support.
61 if (!gpgme_check_version(MIN_GPGME_VERSION)) { 63 if (!gpgme_check_version(MIN_GPGME_VERSION)) {
62 scr_LogPrint(LPRINT_LOGNORM, 64 scr_LogPrint(LPRINT_LOGNORM,
63 "GPGME initialization error: Bad library version"); 65 "GPGME initialization error: Bad library version");
72 } 74 }
73 75
74 // Set the locale information. 76 // Set the locale information.
75 gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL)); 77 gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL));
76 gpgme_set_locale(NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL)); 78 gpgme_set_locale(NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL));
79
80 // The path to the gpg binary can be specified in order to force
81 // version 1, for example.
82 gpg_path = settings_opt_get("gpg_path");
83 if (gpg_path) {
84 err = gpgme_set_engine_info(GPGME_PROTOCOL_OpenPGP, gpg_path, NULL);
85 if (err) return -1;
86 }
77 87
78 // Store private data. 88 // Store private data.
79 gpg_set_private_key(priv_key); 89 gpg_set_private_key(priv_key);
80 gpg_set_passphrase(passphrase); 90 gpg_set_passphrase(passphrase);
81 91