[evolution-data-server] Bug 759392 - Allow custom gpg binary
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 759392 - Allow custom gpg binary
- Date: Tue, 19 Jan 2016 18:34:12 +0000 (UTC)
commit d1cb6c370bc006fb6867d1003c80be915dd5161f
Author: Milan Crha <mcrha redhat com>
Date: Tue Jan 19 19:33:44 2016 +0100
Bug 759392 - Allow custom gpg binary
camel/camel-gpg-context.c | 31 ++++++++++++++++++-
.../org.gnome.evolution-data-server.gschema.xml.in | 5 +++
2 files changed, 34 insertions(+), 2 deletions(-)
---
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c
index 969e8ce..9f70168 100644
--- a/camel/camel-gpg-context.c
+++ b/camel/camel-gpg-context.c
@@ -39,6 +39,7 @@
#include <errno.h>
#include <ctype.h>
+#include <glib.h>
#include <glib/gi18n-lib.h>
#include <glib/gstdio.h>
@@ -471,15 +472,41 @@ static const gchar *
gpg_ctx_get_executable_name (void)
{
static gint index = -1;
+ static gchar preset_binary[512 + 1];
const gchar *names[] = {
+ "",
"gpg",
"gpg2", /* Prefer gpg for now, because gpg2 doesn't save passwords (neither for the session)
*/
NULL
};
+ names[0] = preset_binary;
+
if (index == -1) {
+ GSettings *settings;
+ gchar *path;
+
+ settings = g_settings_new ("org.gnome.evolution-data-server");
+ path = g_settings_get_string (settings, "camel-gpg-binary");
+ g_clear_object (&settings);
+
+ preset_binary[0] = 0;
+
+ if (path && *path && g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
+ if (strlen (path) > 512) {
+ g_warning ("%s: Path is longer than expected (max 512), ignoring it;
value:'%s'", G_STRFUNC, path);
+ } else {
+ strcpy (preset_binary, path);
+ }
+ }
+
+ g_free (path);
+
for (index = 0; names[index]; index++) {
- gchar *path = g_find_program_in_path (names[index]);
+ if (!*(names[index]))
+ continue;
+
+ path = g_find_program_in_path (names[index]);
if (path) {
g_free (path);
@@ -488,7 +515,7 @@ gpg_ctx_get_executable_name (void)
}
if (!names[index])
- index = 0;
+ index = 1;
}
return names[index];
diff --git a/data/org.gnome.evolution-data-server.gschema.xml.in
b/data/org.gnome.evolution-data-server.gschema.xml.in
index 1b38cda..ff670a1 100644
--- a/data/org.gnome.evolution-data-server.gschema.xml.in
+++ b/data/org.gnome.evolution-data-server.gschema.xml.in
@@ -4,5 +4,10 @@
<default>false</default>
<_summary>Whether the migration of old setting was already done</_summary>
</key>
+ <key name="camel-gpg-binary" type="s">
+ <default>''</default>
+ <_summary>An absolute path where the gpg (or gpg2) binary is</_summary>
+ <_description>An example is '/usr/bin/gpg'; if it is not filled, or doesn't exist, then it is searched
for it. Change requires restart of the application.</_description>
+ </key>
</schema>
</schemalist>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]