mirror of
https://gitlab.gnome.org/GNOME/libsecret.git
synced 2024-12-22 04:38:55 +00:00
secret-password: Add lookup_binary functions
This adds a set of functions that return a SecretValue instead of a text password when looking up a secret. This is useful if the stored password is not null-terminated.
This commit is contained in:
parent
5fedca8ffc
commit
bac85c00fc
@ -128,6 +128,9 @@ secret_password_lookup_sync
|
||||
secret_password_lookup_nonpageable_sync
|
||||
secret_password_lookupv_sync
|
||||
secret_password_lookupv_nonpageable_sync
|
||||
secret_password_lookup_binary_finish
|
||||
secret_password_lookup_binary_sync
|
||||
secret_password_lookupv_binary_sync
|
||||
secret_password_clear
|
||||
secret_password_clearv
|
||||
secret_password_clear_finish
|
||||
|
@ -407,6 +407,27 @@ secret_password_lookup_nonpageable_finish (GAsyncResult *result,
|
||||
return _secret_value_unref_to_password (value);
|
||||
}
|
||||
|
||||
/**
|
||||
* secret_password_lookup_binary_finish: (skip)
|
||||
* @result: the asynchronous result passed to the callback
|
||||
* @error: location to place an error on failure
|
||||
*
|
||||
* Finish an asynchronous operation to lookup a password in the secret service.
|
||||
*
|
||||
* Returns: (transfer full): a newly allocated #SecretValue, which should be
|
||||
* released with secret_value_unref(), or %NULL if no secret found
|
||||
*
|
||||
* Since: 0.19.0
|
||||
*/
|
||||
SecretValue *
|
||||
secret_password_lookup_binary_finish (GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
return secret_service_lookup_finish (NULL, result, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* secret_password_lookup_finish:
|
||||
* @result: the asynchronous result passed to the callback
|
||||
@ -589,6 +610,110 @@ secret_password_lookupv_nonpageable_sync (const SecretSchema *schema,
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* secret_password_lookup_binary_sync: (skip)
|
||||
* @schema: the schema for the attributes
|
||||
* @cancellable: optional cancellation object
|
||||
* @error: location to place an error on failure
|
||||
* @...: the attribute keys and values, terminated with %NULL
|
||||
*
|
||||
* Lookup a password in the secret service.
|
||||
*
|
||||
* This is similar to secret_password_lookup_sync(), but returns a
|
||||
* #SecretValue instead of a null-terminated password.
|
||||
*
|
||||
* This method may block indefinitely and should not be used in user interface
|
||||
* threads.
|
||||
*
|
||||
* Returns: (transfer full): a newly allocated #SecretValue, which should be
|
||||
* released with secret_value_unref(), or %NULL if no secret found
|
||||
*
|
||||
* Since: 0.19.0
|
||||
*/
|
||||
SecretValue *
|
||||
secret_password_lookup_binary_sync (const SecretSchema *schema,
|
||||
GCancellable *cancellable,
|
||||
GError **error,
|
||||
...)
|
||||
{
|
||||
GHashTable *attributes;
|
||||
SecretValue *value;
|
||||
va_list va;
|
||||
|
||||
g_return_val_if_fail (schema != NULL, NULL);
|
||||
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
va_start (va, error);
|
||||
attributes = secret_attributes_buildv (schema, va);
|
||||
va_end (va);
|
||||
|
||||
/* Precondition failed, already warned */
|
||||
if (!attributes)
|
||||
return NULL;
|
||||
|
||||
value = secret_password_lookupv_binary_sync (schema, attributes,
|
||||
cancellable, error);
|
||||
|
||||
g_hash_table_unref (attributes);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* secret_password_lookupv_binary_sync: (skip)
|
||||
* @schema: the schema for attributes
|
||||
* @attributes: (element-type utf8 utf8): the attribute keys and values
|
||||
* @cancellable: optional cancellation object
|
||||
* @error: location to place an error on failure
|
||||
*
|
||||
* Lookup a password in the secret service.
|
||||
*
|
||||
* This is similar to secret_password_lookupv_sync(), but returns a
|
||||
* #SecretValue instead of a null-terminated password.
|
||||
*
|
||||
* This method may block indefinitely and should not be used in user interface
|
||||
* threads.
|
||||
*
|
||||
* Returns: (transfer full): a newly allocated #SecretValue, which should be
|
||||
* released with secret_value_unref(), or %NULL if no secret found
|
||||
*
|
||||
* Since: 0.19.0
|
||||
*/
|
||||
SecretValue *
|
||||
secret_password_lookupv_binary_sync (const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
SecretSync *sync;
|
||||
SecretValue *value;
|
||||
|
||||
g_return_val_if_fail (schema != NULL, NULL);
|
||||
g_return_val_if_fail (attributes != NULL, NULL);
|
||||
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
/* Warnings raised already */
|
||||
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
|
||||
return FALSE;
|
||||
|
||||
sync = _secret_sync_new ();
|
||||
g_main_context_push_thread_default (sync->context);
|
||||
|
||||
secret_password_lookupv (schema, attributes, cancellable,
|
||||
_secret_sync_on_result, sync);
|
||||
|
||||
g_main_loop_run (sync->loop);
|
||||
|
||||
value = secret_password_lookup_binary_finish (sync->result, error);
|
||||
|
||||
g_main_context_pop_thread_default (sync->context);
|
||||
_secret_sync_free (sync);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* secret_password_lookupv_sync: (rename-to secret_password_lookup_sync)
|
||||
* @schema: the schema for attributes
|
||||
|
@ -25,8 +25,9 @@ G_BEGIN_DECLS
|
||||
|
||||
#include "secret-schema.h"
|
||||
#include "secret-types.h"
|
||||
#include "secret-value.h"
|
||||
|
||||
void secret_password_store (const SecretSchema *schema,
|
||||
void secret_password_store (const SecretSchema *schema,
|
||||
const gchar *collection,
|
||||
const gchar *label,
|
||||
const gchar *password,
|
||||
@ -35,7 +36,7 @@ void secret_password_store (const SecretSchema *sche
|
||||
gpointer user_data,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
void secret_password_storev (const SecretSchema *schema,
|
||||
void secret_password_storev (const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
const gchar *collection,
|
||||
const gchar *label,
|
||||
@ -44,10 +45,10 @@ void secret_password_storev (const SecretSchema *sche
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean secret_password_store_finish (GAsyncResult *result,
|
||||
gboolean secret_password_store_finish (GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gboolean secret_password_store_sync (const SecretSchema *schema,
|
||||
gboolean secret_password_store_sync (const SecretSchema *schema,
|
||||
const gchar *collection,
|
||||
const gchar *label,
|
||||
const gchar *password,
|
||||
@ -55,7 +56,7 @@ gboolean secret_password_store_sync (const SecretSchema *sche
|
||||
GError **error,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
gboolean secret_password_storev_sync (const SecretSchema *schema,
|
||||
gboolean secret_password_storev_sync (const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
const gchar *collection,
|
||||
const gchar *label,
|
||||
@ -63,101 +64,111 @@ gboolean secret_password_storev_sync (const SecretSchema *sche
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void secret_password_lookup (const SecretSchema *schema,
|
||||
void secret_password_lookup (const SecretSchema *schema,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
void secret_password_lookupv (const SecretSchema *schema,
|
||||
void secret_password_lookupv (const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
gchar * secret_password_lookup_finish (GAsyncResult *result,
|
||||
gchar * secret_password_lookup_finish (GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gchar * secret_password_lookup_nonpageable_finish (GAsyncResult *result,
|
||||
GError **error);
|
||||
gchar * secret_password_lookup_nonpageable_finish (GAsyncResult *result,
|
||||
GError **error);
|
||||
SecretValue *secret_password_lookup_binary_finish (GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gchar * secret_password_lookup_sync (const SecretSchema *schema,
|
||||
gchar * secret_password_lookup_sync (const SecretSchema *schema,
|
||||
GCancellable *cancellable,
|
||||
GError **error,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
gchar * secret_password_lookup_nonpageable_sync (const SecretSchema *schema,
|
||||
gchar * secret_password_lookup_nonpageable_sync (const SecretSchema *schema,
|
||||
GCancellable *cancellable,
|
||||
GError **error,
|
||||
...);
|
||||
SecretValue *secret_password_lookup_binary_sync (const SecretSchema *schema,
|
||||
GCancellable *cancellable,
|
||||
GError **error,
|
||||
...);
|
||||
|
||||
gchar * secret_password_lookupv_sync (const SecretSchema *schema,
|
||||
gchar * secret_password_lookupv_sync (const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
gchar * secret_password_lookupv_nonpageable_sync (const SecretSchema *schema,
|
||||
gchar * secret_password_lookupv_nonpageable_sync (const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
SecretValue *secret_password_lookupv_binary_sync (const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void secret_password_clear (const SecretSchema *schema,
|
||||
void secret_password_clear (const SecretSchema *schema,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
void secret_password_clearv (const SecretSchema *schema,
|
||||
void secret_password_clearv (const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean secret_password_clear_finish (GAsyncResult *result,
|
||||
gboolean secret_password_clear_finish (GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gboolean secret_password_clear_sync (const SecretSchema* schema,
|
||||
gboolean secret_password_clear_sync (const SecretSchema* schema,
|
||||
GCancellable *cancellable,
|
||||
GError **error,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
gboolean secret_password_clearv_sync (const SecretSchema *schema,
|
||||
gboolean secret_password_clearv_sync (const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void secret_password_search (const SecretSchema *schema,
|
||||
void secret_password_search (const SecretSchema *schema,
|
||||
SecretSearchFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
void secret_password_searchv (const SecretSchema *schema,
|
||||
void secret_password_searchv (const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
SecretSearchFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GList * secret_password_search_sync (const SecretSchema *schema,
|
||||
GList * secret_password_search_sync (const SecretSchema *schema,
|
||||
SecretSearchFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GError **error,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
GList * secret_password_searchv_sync (const SecretSchema *schema,
|
||||
GList * secret_password_searchv_sync (const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
SecretSearchFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
GList * secret_password_search_finish (GAsyncResult *result,
|
||||
GList * secret_password_search_finish (GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
void secret_password_free (gchar *password);
|
||||
void secret_password_free (gchar *password);
|
||||
|
||||
void secret_password_wipe (gchar *password);
|
||||
void secret_password_wipe (gchar *password);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user