[network-manager-applet/thaller/rh1000564_wifi_security_userpass: 2/2] editor: remember/restore old password when toggle ask_password in wifi
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/thaller/rh1000564_wifi_security_userpass: 2/2] editor: remember/restore old password when toggle ask_password in wifi
- Date: Mon, 26 Aug 2013 11:19:01 +0000 (UTC)
commit bdfb959e4782d7830dd8546a8ff27fec81fc5556
Author: Thomas Haller <thaller redhat com>
Date: Fri Aug 23 21:33:04 2013 +0200
editor: remember/restore old password when toggle ask_password in wifi
In the wifi security dialog, when you set the "always ask" checkbox, the
password will be cleared. Remember the previous password and restore it when
you uncheck the box again.
This has the effect, that you can toggle this checkbox and don't have to
reenter the password.
This only works, as long as you don't change the "Security",
"Authentication" or "Inner authentication" type. This is
intentionally not to expose the password by accident.
Signed-off-by: Thomas Haller <thaller redhat com>
src/wireless-security/eap-method-simple.c | 33 ++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/src/wireless-security/eap-method-simple.c b/src/wireless-security/eap-method-simple.c
index b5ffa70..3c40028 100644
--- a/src/wireless-security/eap-method-simple.c
+++ b/src/wireless-security/eap-method-simple.c
@@ -175,14 +175,42 @@ update_secrets (EAPMethod *parent, NMConnection *connection)
}
static void
+g_free_str0 (gpointer mem)
+{
+ /* g_free a char pointer and set it to 0 before (for passwords). */
+ if (mem) {
+ char *p = mem;
+ memset (p, 0, strlen (p));
+ g_free (p);
+ }
+}
+
+static void
password_always_ask_changed (GtkToggleButton *button, EAPMethodSimple *method)
{
+ char *password, *password_old;
gboolean always_ask;
always_ask = gtk_toggle_button_get_active (button);
+ password = g_strdup (gtk_entry_get_text (method->password_entry));
+ password_old = g_object_steal_data (G_OBJECT (method->password_entry), "password-old");
if (always_ask) {
- gtk_entry_set_text (method->password_entry, "");
+ g_free_str0 (password_old);
+ password_old = password;
+ password = NULL;
+ } else {
+ g_free_str0 (password);
+ password = password_old;
+ password_old = NULL;
+ }
+ gtk_entry_set_text (method->password_entry, password ? password : "");
+ g_free_str0 (password);
+ g_object_set_data_full (G_OBJECT (method->password_entry), "password-old", password_old, g_free_str0);
+
+ if (always_ask) {
+ /* we always clear this button and do not restore it
+ * (because we want to hide the password). */
gtk_toggle_button_set_active (method->show_password, FALSE);
}
@@ -215,6 +243,9 @@ widgets_unrealized (GtkWidget *widget, EAPMethodSimple *method)
gtk_entry_get_text (method->password_entry),
gtk_toggle_button_get_active (method->always_ask),
gtk_toggle_button_get_active (method->show_password));
+
+ /* clear the remembered password. If the user changes the scheme, its gone. */
+ g_object_set_data(G_OBJECT (method->password_entry), "password-old", NULL);
}
EAPMethodSimple *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]