diff options
author | Thomas Haller <thaller@redhat.com> | 2013-08-23 21:33:04 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2013-08-28 11:31:55 +0200 |
commit | c6ef0298bb096b08bccfc47e215bdfd6295c1fd8 (patch) | |
tree | c4e910d99c30239b750fdb187a8fe2097ea8505d | |
parent | 3cae06120a4dd9bebd5f2e57e181ea95e87c8ac4 (diff) | |
download | network-manager-applet-c6ef0298bb096b08bccfc47e215bdfd6295c1fd8.tar.gz |
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>
-rw-r--r-- | src/wireless-security/eap-method-simple.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/wireless-security/eap-method-simple.c b/src/wireless-security/eap-method-simple.c index 90ae9142..60bd11fe 100644 --- a/src/wireless-security/eap-method-simple.c +++ b/src/wireless-security/eap-method-simple.c @@ -175,14 +175,37 @@ 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; gboolean always_ask; always_ask = gtk_toggle_button_get_active (button); if (always_ask) { + password = g_strdup (gtk_entry_get_text (method->password_entry)); gtk_entry_set_text (method->password_entry, ""); + g_object_set_data_full (G_OBJECT (method->password_entry), "password-old", password, g_free_str0); + } else { + password = g_object_get_data (G_OBJECT (method->password_entry), "password-old"); + gtk_entry_set_text (method->password_entry, password ? password : ""); + g_object_set_data(G_OBJECT (method->password_entry), "password-old", NULL); + } + + 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 +238,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, it's gone. */ + g_object_set_data(G_OBJECT (method->password_entry), "password-old", NULL); } static void |