[libsecret/wip/dueno/local-file: 4/4] password: Hook storage backend functions
- From: Daiki Ueno <dueno src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsecret/wip/dueno/local-file: 4/4] password: Hook storage backend functions
- Date: Sun, 23 Sep 2018 13:18:47 +0000 (UTC)
commit 53178da75f5a66fac36bb0a22e7156ccdc375b7b
Author: Daiki Ueno <dueno src gnome org>
Date: Sun Sep 23 15:00:01 2018 +0200
password: Hook storage backend functions
libsecret/secret-password.c | 54 ++++++++++++++++++++++++++++++++++++---------
1 file changed, 44 insertions(+), 10 deletions(-)
---
diff --git a/libsecret/secret-password.c b/libsecret/secret-password.c
index 149995d..45bf5e1 100644
--- a/libsecret/secret-password.c
+++ b/libsecret/secret-password.c
@@ -17,6 +17,7 @@
#include "secret-attributes.h"
#include "secret-password.h"
#include "secret-private.h"
+#include "secret-storage.h"
#include "secret-value.h"
#include <egg/egg-secure-memory.h>
@@ -42,6 +43,15 @@
* Stability: Stable
*/
+static gboolean
+_secret_password_use_storage (void)
+{
+ const gchar *envvar;
+
+ envvar = g_getenv ("SECRET_STORAGE_PASSWORD");
+ return envvar && *envvar != '\0';
+}
+
/**
* secret_password_store: (skip)
* @schema: the schema for attributes
@@ -149,8 +159,12 @@ secret_password_storev (const SecretSchema *schema,
value = secret_value_new (password, -1, "text/plain");
- secret_service_store (NULL, schema, attributes, collection,
- label, value, cancellable, callback, user_data);
+ if (_secret_password_use_storage ())
+ secret_storage_store (NULL, schema, attributes, collection,
+ label, value, cancellable, callback, user_data);
+ else
+ secret_service_store (NULL, schema, attributes, collection,
+ label, value, cancellable, callback, user_data);
secret_value_unref (value);
}
@@ -169,7 +183,10 @@ secret_password_store_finish (GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- return secret_service_store_finish (NULL, result, error);
+ if (_secret_password_use_storage ())
+ return secret_storage_store_finish (NULL, result, error);
+ else
+ return secret_service_store_finish (NULL, result, error);
}
/**
@@ -377,8 +394,12 @@ secret_password_lookupv (const SecretSchema *schema,
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
return;
- secret_service_lookup (NULL, schema, attributes,
- cancellable, callback, user_data);
+ if (_secret_password_use_storage ())
+ secret_storage_lookup (NULL, schema, attributes,
+ cancellable, callback, user_data);
+ else
+ secret_service_lookup (NULL, schema, attributes,
+ cancellable, callback, user_data);
}
/**
@@ -399,7 +420,10 @@ secret_password_lookup_nonpageable_finish (GAsyncResult *result,
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- value = secret_service_lookup_finish (NULL, result, error);
+ if (_secret_password_use_storage ())
+ value = secret_storage_lookup_finish (NULL, result, error);
+ else
+ value = secret_service_lookup_finish (NULL, result, error);
if (value == NULL)
return NULL;
@@ -424,7 +448,10 @@ secret_password_lookup_finish (GAsyncResult *result,
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- value = secret_service_lookup_finish (NULL, result, error);
+ if (_secret_password_use_storage ())
+ value = secret_storage_lookup_finish (NULL, result, error);
+ else
+ value = secret_service_lookup_finish (NULL, result, error);
if (value == NULL)
return NULL;
@@ -719,8 +746,12 @@ secret_password_clearv (const SecretSchema *schema,
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
return;
- secret_service_clear (NULL, schema, attributes,
- cancellable, callback, user_data);
+ if (_secret_password_use_storage ())
+ secret_storage_clear (NULL, schema, attributes,
+ cancellable, callback, user_data);
+ else
+ secret_service_clear (NULL, schema, attributes,
+ cancellable, callback, user_data);
}
/**
@@ -738,7 +769,10 @@ secret_password_clear_finish (GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- return secret_service_clear_finish (NULL, result, error);
+ if (_secret_password_use_storage ())
+ return secret_storage_clear_finish (NULL, result, error);
+ else
+ return secret_service_clear_finish (NULL, result, error);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]