[gnome-control-center/wip/oholy/libpwquality-crashes: 24/25] user-accounts: Do not crash because of libpwquality failures
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/oholy/libpwquality-crashes: 24/25] user-accounts: Do not crash because of libpwquality failures
- Date: Mon, 10 Sep 2018 22:04:43 +0000 (UTC)
commit 64007ce52d3dd9c6612608c058ab157486a65869
Author: Ondrej Holy <oholy redhat com>
Date: Thu Aug 30 16:28:20 2018 +0200
user-accounts: Do not crash because of libpwquality failures
Users panel crashes with g_error() if some of libpwquality calls fails,
e.g. when pwquality.conf is broken. The default values should be used
instead of crash. Let's use g_warning() instead of g_error() in that
case.
https://gitlab.gnome.org/GNOME/gnome-control-center/issues/171
panels/user-accounts/pw-utils.c | 13 +++++++++----
panels/user-accounts/um-account-dialog.c | 2 ++
panels/user-accounts/um-password-dialog.c | 2 ++
3 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/panels/user-accounts/pw-utils.c b/panels/user-accounts/pw-utils.c
index 8b2c39ff9..5a07036e5 100644
--- a/panels/user-accounts/pw-utils.c
+++ b/panels/user-accounts/pw-utils.c
@@ -37,7 +37,12 @@ get_pwq (void)
settings = pwquality_default_settings ();
pwquality_set_int_value (settings, PWQ_SETTING_MAX_SEQUENCE, 4);
if (pwquality_read_config (settings, NULL, (gpointer)&err) < 0) {
- g_error ("failed to read pwquality configuration: %s\n", err);
+ g_warning ("failed to read pwquality configuration: %s\n", err);
+ pwquality_free_settings (settings);
+
+ /* Load just default settings in case of failure. */
+ settings = pwquality_default_settings ();
+ pwquality_set_int_value (settings, PWQ_SETTING_MAX_SEQUENCE, 4);
}
}
@@ -50,7 +55,7 @@ pw_min_length (void)
gint value = 0;
if (pwquality_get_int_value (get_pwq (), PWQ_SETTING_MIN_LENGTH, &value) < 0) {
- g_error ("Failed to read pwquality setting\n" );
+ g_warning ("Failed to read pwquality setting\n");
}
return value;
@@ -65,8 +70,8 @@ pw_generate (void)
rv = pwquality_generate (get_pwq (), 0, &res);
if (rv < 0) {
- g_error ("Password generation failed: %s\n",
- pwquality_strerror (NULL, 0, rv, NULL));
+ g_warning ("Password generation failed: %s\n",
+ pwquality_strerror (NULL, 0, rv, NULL));
return NULL;
}
diff --git a/panels/user-accounts/um-account-dialog.c b/panels/user-accounts/um-account-dialog.c
index 2b68d74f9..613e5751a 100644
--- a/panels/user-accounts/um-account-dialog.c
+++ b/panels/user-accounts/um-account-dialog.c
@@ -479,6 +479,8 @@ on_generate (GtkEntry *entry,
gchar *pwd;
pwd = pw_generate ();
+ if (pwd == NULL)
+ return;
gtk_entry_set_text (GTK_ENTRY (self->local_password), pwd);
gtk_entry_set_text (GTK_ENTRY (self->local_verify), pwd);
diff --git a/panels/user-accounts/um-password-dialog.c b/panels/user-accounts/um-password-dialog.c
index 0ea1e715d..310259c37 100644
--- a/panels/user-accounts/um-password-dialog.c
+++ b/panels/user-accounts/um-password-dialog.c
@@ -439,6 +439,8 @@ on_generate (GtkEntry *entry,
gchar *pwd;
pwd = pw_generate ();
+ if (pwd == NULL)
+ return;
gtk_entry_set_text (GTK_ENTRY (um->password_entry), pwd);
gtk_entry_set_text (GTK_ENTRY (um->verify_entry), pwd);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]