summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2010-09-07 23:19:08 +0000
committerStef Walter <stef@memberwebs.com>2010-09-07 23:19:08 +0000
commit01353183e687934b18be9ca2aae8d5b44a4ef1ab (patch)
tree557d9151172b1a5f8317da8ae4cd587ee1da7bf0
parent997ab708d25af38b49369733ffda27d861e45ee4 (diff)
downloadgnome-keyring-01353183e687934b18be9ca2aae8d5b44a4ef1ab.tar.gz
[gpg-agent] Add gsettings to store passphrase preferences.
Depends on new glib 2.25.0 and later.
-rw-r--r--.gitignore1
-rw-r--r--Makefile.am1
-rwxr-xr-xautogen.sh1
-rw-r--r--configure.in5
-rw-r--r--daemon/gpg-agent/gkd-gpg-agent-ops.c51
-rw-r--r--daemon/gpg-agent/gkd-gpg-agent-private.h2
-rw-r--r--daemon/gpg-agent/gkd-gpg-agent.c21
-rw-r--r--schema/Makefile.am15
-rw-r--r--schema/org.gnome.crypto.cache.convert3
-rw-r--r--schema/org.gnome.crypto.cache.gschema.xml9
10 files changed, 105 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index a54fbec6..6b69fd1a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,6 +32,7 @@ run-tests
*.gcov
*.gcno
*.gcda
+*.valid
/compile
/ABOUT-NLS
diff --git a/Makefile.am b/Makefile.am
index ca70b917..d530f882 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,6 +17,7 @@ SUBDIRS = \
gcr \
ui \
pkcs11 \
+ schema \
daemon \
tool \
$(TESTS_DIR) \
diff --git a/autogen.sh b/autogen.sh
index dccb1842..2631ac64 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -5,7 +5,6 @@ srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
PKG_NAME="gnome-keyring"
-REQUIRED_AUTOMAKE_VERSION=1.6
(test -f $srcdir/configure.in \
&& test -f $srcdir/daemon/gkd-main.c) || {
diff --git a/configure.in b/configure.in
index ec67e8f7..1cafd53c 100644
--- a/configure.in
+++ b/configure.in
@@ -78,7 +78,7 @@ PKG_CHECK_MODULES(GOBJECT, glib-2.0 >= 2.16.0 gobject-2.0 >= 2.8.0)
AC_SUBST(GOBJECT_CFLAGS)
AC_SUBST(GOBJECT_LIBS)
-PKG_CHECK_MODULES(GIO, glib-2.0 >= 2.16.0 gio-2.0)
+PKG_CHECK_MODULES(GIO, glib-2.0 >= 2.25.0 gio-2.0)
AC_SUBST(GIO_CFLAGS)
AC_SUBST(GIO_LIBS)
@@ -121,6 +121,8 @@ AM_GLIB_GNU_GETTEXT
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
+GLIB_GSETTINGS
+
# --------------------------------------------------------------------
# Check for socklen_t
#
@@ -691,6 +693,7 @@ pkcs11/user-store/tests/Makefile
pkcs11/wrap-layer/Makefile
pkcs11/wrap-layer/tests/Makefile
po/Makefile.in
+schema/Makefile
testing/Makefile
tool/Makefile
ui/Makefile
diff --git a/daemon/gpg-agent/gkd-gpg-agent-ops.c b/daemon/gpg-agent/gkd-gpg-agent-ops.c
index 556e9956..69bbbd43 100644
--- a/daemon/gpg-agent/gkd-gpg-agent-ops.c
+++ b/daemon/gpg-agent/gkd-gpg-agent-ops.c
@@ -289,6 +289,53 @@ do_lookup_password (GP11Session *session, const gchar *keyid)
return data;
}
+static void
+load_unlock_options (GkuPrompt *prompt)
+{
+ GSettings *settings;
+ gchar *method;
+ gint ttl;
+
+ settings = gkd_gpg_agent_settings ();
+
+ method = g_settings_get_string (settings, "gpg-cache-method");
+ if (!method) {
+ method = g_strdup (GCR_UNLOCK_OPTION_SESSION);
+
+ /* COMPAT: with old seahorse-agent settings that were migrated */
+ } else if (g_str_equal (method, "gnome")) {
+ g_free (method);
+ method = g_strdup (GCR_UNLOCK_OPTION_ALWAYS);
+ } else if (g_str_equal (method, "internal")) {
+ g_free (method);
+ method = g_strdup (GCR_UNLOCK_OPTION_SESSION);
+ }
+
+ gku_prompt_set_unlock_choice (prompt, method);
+ g_free (method);
+
+ ttl = g_settings_get_int (settings, "gpg-cache-ttl");
+ gku_prompt_set_unlock_ttl (prompt, ttl <= 0 ? 1 : (guint)ttl);
+}
+
+static void
+save_unlock_options (GkuPrompt *prompt)
+{
+ GSettings *settings;
+ const gchar *method;
+ gint ttl;
+
+ settings = gkd_gpg_agent_settings ();
+
+ method = gku_prompt_get_unlock_choice (prompt);
+ if (method)
+ g_settings_set_string (settings, "gpg-cache-method", method);
+
+ ttl = gku_prompt_get_unlock_ttl (prompt);
+ if (ttl >= 0)
+ g_settings_set_int (settings, "gpg-cache-ttl", (gint)ttl);
+}
+
static GkuPrompt*
prepare_password_prompt (GP11Session *session, const gchar *errmsg, const gchar *prompt_text,
const gchar *description, gboolean confirm)
@@ -339,6 +386,8 @@ prepare_password_prompt (GP11Session *session, const gchar *errmsg, const gchar
gku_prompt_set_unlock_label (prompt, GCR_UNLOCK_OPTION_TIMEOUT, _("Forget this password after"));
gku_prompt_set_unlock_label (prompt, GCR_UNLOCK_OPTION_SESSION, _("Forget this password when I log out"));
+ load_unlock_options (prompt);
+
gp11_list_unref_free (objects);
return prompt;
@@ -398,6 +447,8 @@ do_get_password (GP11Session *session, const gchar *keyid, const gchar *errmsg,
/* Now actually save the password */
do_save_password (session, keyid, description, password, attrs);
gp11_attributes_unref (attrs);
+
+ save_unlock_options (prompt);
}
g_object_unref (prompt);
diff --git a/daemon/gpg-agent/gkd-gpg-agent-private.h b/daemon/gpg-agent/gkd-gpg-agent-private.h
index 5688354d..b824e4f8 100644
--- a/daemon/gpg-agent/gkd-gpg-agent-private.h
+++ b/daemon/gpg-agent/gkd-gpg-agent-private.h
@@ -85,6 +85,8 @@ gboolean gkd_gpg_agent_send_reply (GkdGpgAgent
gboolean gkd_gpg_agent_send_data (GkdGpgAgentCall *call,
const gchar *data);
+GSettings* gkd_gpg_agent_settings (void);
+
/* -----------------------------------------------------------------------------
* gkd-gpg-agent-ops
*/
diff --git a/daemon/gpg-agent/gkd-gpg-agent.c b/daemon/gpg-agent/gkd-gpg-agent.c
index 67d7cef1..32b02c19 100644
--- a/daemon/gpg-agent/gkd-gpg-agent.c
+++ b/daemon/gpg-agent/gkd-gpg-agent.c
@@ -256,6 +256,20 @@ gkd_gpg_agent_checkin_main_session (GP11Session *session)
}
/* --------------------------------------------------------------------------------------
+ * SETTINGS
+ */
+
+/* The cache settings */
+static GSettings *cache_settings = NULL;
+
+GSettings*
+gkd_gpg_agent_settings (void)
+{
+ g_return_val_if_fail (cache_settings, NULL);
+ return cache_settings;
+}
+
+/* --------------------------------------------------------------------------------------
* MAIN THREAD
*/
@@ -370,6 +384,11 @@ gkd_gpg_agent_uninitialize (void)
g_assert (pkcs11_module);
g_object_unref (pkcs11_module);
+ pkcs11_module = NULL;
+
+ g_assert (cache_settings);
+ g_object_unref (cache_settings);
+ cache_settings = NULL;
}
int
@@ -435,6 +454,8 @@ gkd_gpg_agent_initialize_with_module (GP11Module *module)
pkcs11_main_checked = FALSE;
pkcs11_main_session = session;
+ cache_settings = g_settings_new ("org.gnome.crypto.cache");
+
return TRUE;
}
diff --git a/schema/Makefile.am b/schema/Makefile.am
new file mode 100644
index 00000000..b0f2eefe
--- /dev/null
+++ b/schema/Makefile.am
@@ -0,0 +1,15 @@
+
+gsettings_SCHEMAS = \
+ org.gnome.crypto.cache.gschema.xml
+
+@GSETTINGS_RULES@
+
+convert_DATA = \
+ org.gnome.crypto.cache.convert
+
+convertdir = \
+ $(datarootdir)/GConf/gsettings
+
+EXTRA_DIST = \
+ $(convert_DATA) \
+ $(gsettings_SCHEMAS) \ No newline at end of file
diff --git a/schema/org.gnome.crypto.cache.convert b/schema/org.gnome.crypto.cache.convert
new file mode 100644
index 00000000..b329e16f
--- /dev/null
+++ b/schema/org.gnome.crypto.cache.convert
@@ -0,0 +1,3 @@
+[org.gnome.crypto.cache]
+gpg-cache-method = /apps/seahorse/agent/cache_method
+gpg-cache-ttl = /apps/seahorse/agent/cache_ttl
diff --git a/schema/org.gnome.crypto.cache.gschema.xml b/schema/org.gnome.crypto.cache.gschema.xml
index 7e4d9b27..9a431eb4 100644
--- a/schema/org.gnome.crypto.cache.gschema.xml
+++ b/schema/org.gnome.crypto.cache.gschema.xml
@@ -1,12 +1,17 @@
<schemalist>
<schema id="org.gnome.crypto.cache" path="/desktop/gnome/crypto/cache/">
<key name="gpg-cache-method" type="s">
- <default>session</default>
+ <default>'session'</default>
<summary>Cache Method</summary>
<description>The method to use for caching passphrases typed into the GPG agent.</description>
</key>
+ <key name="gpg-cache-ttl" type="i">
+ <default>300</default>
+ <summary>Cache Time To Live</summary>
+ <description>The amount of time in seconds to cache passphrases when the 'idle' or 'timeout' gpg-cache-method are in use.</description>
+ </key>
<key name="gpg-cache-authorize" type="b">
- <default>FALSE</default>
+ <default>false</default>
<summary>Authorize Cache Access</summary>
<description>Not yet implemented.</description>
</key>