summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Kramlich <grim@reaperworld.com>2021-08-23 07:16:01 -0500
committerGary Kramlich <grim@reaperworld.com>2021-08-23 07:16:01 -0500
commit6808d3ab315b6ac29195fbf73ae17ea23181386e (patch)
tree03794427e808f4aae1103c25871781b299b5cb4e
parentc2513fabc0090505365d7b67052a4191142063dd (diff)
downloadpidgin-6808d3ab315b6ac29195fbf73ae17ea23181386e.tar.gz
Don't error out when trying to remove a password that isn't stored.
Both wincred and secretservice return an error if you try to delete a password that they don't know about. We don't care about this scenario and just want to make sure the password is gone, so we changed the expected behavior to be as such and updated wincred and secret service for the change. I also fixed the NULL deference which is how I stumbled across the issue in the first place. Testing Done: * Verfied the issue was fixed in secretservice. * Verfied the issue didn't exist in kwallet. Reviewed at https://reviews.imfreedom.org/r/901/
-rw-r--r--libpurple/accounts.c2
-rw-r--r--libpurple/plugins/keyrings/secretservice.c10
-rw-r--r--libpurple/plugins/keyrings/wincred.c36
-rw-r--r--libpurple/purplecredentialmanager.h4
-rw-r--r--libpurple/purplecredentialprovider.h4
5 files changed, 29 insertions, 27 deletions
diff --git a/libpurple/accounts.c b/libpurple/accounts.c
index b61041efa1..cb98989306 100644
--- a/libpurple/accounts.c
+++ b/libpurple/accounts.c
@@ -573,7 +573,7 @@ purple_accounts_delete_set(GObject *obj, GAsyncResult *res, gpointer d) {
purple_debug_warning("accounts",
"Failed to remove password for account %s: %s",
purple_account_get_name_for_display(account),
- error->message);
+ (error != NULL) ? error->message : "Unknown error");
g_clear_error(&error);
}
diff --git a/libpurple/plugins/keyrings/secretservice.c b/libpurple/plugins/keyrings/secretservice.c
index bcaa90474b..18245fbdc6 100644
--- a/libpurple/plugins/keyrings/secretservice.c
+++ b/libpurple/plugins/keyrings/secretservice.c
@@ -123,14 +123,18 @@ purple_secret_service_clear_password_callback(GObject *obj,
{
GTask *task = G_TASK(data);
GError *error = NULL;
- gboolean ret = FALSE;
- ret = secret_password_clear_finish(result, &error);
+ /* This returns whether a password was removed or not. Which means that it
+ * can return FALSE with error unset. This would complicate all of the other
+ * credential API and we don't need to make this distinction, so we just
+ * return TRUE unless error is set.
+ */
+ secret_password_clear_finish(result, &error);
if(error != NULL) {
g_task_return_error(task, error);
} else {
- g_task_return_boolean(task, ret);
+ g_task_return_boolean(task, TRUE);
}
g_object_unref(G_OBJECT(task));
diff --git a/libpurple/plugins/keyrings/wincred.c b/libpurple/plugins/keyrings/wincred.c
index 00ab02be14..5160a15eac 100644
--- a/libpurple/plugins/keyrings/wincred.c
+++ b/libpurple/plugins/keyrings/wincred.c
@@ -292,28 +292,26 @@ purple_wincred_clear_password_async(PurpleCredentialProvider *provider,
DWORD error_code = GetLastError();
if (error_code == ERROR_NOT_FOUND) {
- if (purple_debug_is_verbose()) {
- purple_debug_misc(
+ /* If there was no password we just return TRUE. */
+ g_task_return_boolean(task, TRUE);
+ } else {
+ if (error_code == ERROR_NO_SUCH_LOGON_SESSION) {
+ purple_debug_error(
"keyring-wincred",
- "Password for account %s was already removed.",
- purple_account_get_username(account));
+ "Cannot remove password, no valid logon session");
+ error = g_error_new(
+ PURPLE_WINCRED_ERROR, error_code,
+ _("Cannot remove password, no valid logon session."));
+ } else {
+ purple_debug_error("keyring-wincred",
+ "Cannot remove password, error %lx", error_code);
+ error = g_error_new(
+ PURPLE_WINCRED_ERROR, error_code,
+ _("Cannot remove password (error %lx)."), error_code);
}
- } else if (error_code == ERROR_NO_SUCH_LOGON_SESSION) {
- purple_debug_error(
- "keyring-wincred",
- "Cannot remove password, no valid logon session");
- error = g_error_new(
- PURPLE_WINCRED_ERROR, error_code,
- _("Cannot remove password, no valid logon session."));
- } else {
- purple_debug_error("keyring-wincred",
- "Cannot remove password, error %lx", error_code);
- error = g_error_new(
- PURPLE_WINCRED_ERROR, error_code,
- _("Cannot remove password (error %lx)."), error_code);
- }
- g_task_return_error(task, error);
+ g_task_return_error(task, error);
+ }
}
g_object_unref(G_OBJECT(task));
diff --git a/libpurple/purplecredentialmanager.h b/libpurple/purplecredentialmanager.h
index a43c157657..1a0ba9c38f 100644
--- a/libpurple/purplecredentialmanager.h
+++ b/libpurple/purplecredentialmanager.h
@@ -270,8 +270,8 @@ void purple_credential_manager_clear_password_async(PurpleCredentialManager *man
* Finishes a previous call to
* purple_credential_provider_clear_password_async().
*
- * Returns: %TRUE if the password was cleared successfully, otherwise %FALSE
- * with @error set.
+ * Returns: %TRUE if the password didn't exist or was cleared successfully,
+ * otherwise %FALSE with @error set.
*
* Since: 3.0.0
*/
diff --git a/libpurple/purplecredentialprovider.h b/libpurple/purplecredentialprovider.h
index d230618f10..c4713b94ac 100644
--- a/libpurple/purplecredentialprovider.h
+++ b/libpurple/purplecredentialprovider.h
@@ -269,8 +269,8 @@ void purple_credential_provider_clear_password_async(PurpleCredentialProvider *p
* Finishes a previous call to
* purple_credential_provider_clear_password_async().
*
- * Returns: %TRUE if the password was cleared successfully, otherwise %FALSE
- * with @error set.
+ * Returns: %TRUE if the password didn't exist or was cleared successfully,
+ * otherwise %FALSE with @error set.
*
* Since: 3.0.0
*/