diff options
-rw-r--r-- | data/ui/remmina_unlock.glade | 135 | ||||
-rw-r--r-- | src/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/remmina_pref.c | 21 | ||||
-rw-r--r-- | src/remmina_unlock.c | 17 |
4 files changed, 97 insertions, 79 deletions
diff --git a/data/ui/remmina_unlock.glade b/data/ui/remmina_unlock.glade index 776e1f59d..4e0cc52ac 100644 --- a/data/ui/remmina_unlock.glade +++ b/data/ui/remmina_unlock.glade @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.1 +<!-- Generated with glade 3.38.2 - Copyright © 2014-2022 Antenore Gatta, Giovanni Panozzo @@ -27,27 +27,23 @@ Author: Antenore Gatta <!-- interface-copyright Antenore Gatta, Giovanni Panozzo --> <!-- interface-authors Antenore Gatta --> <object class="GtkDialog" id="RemminaUnlockDialog"> - <property name="can_focus">False</property> - <property name="type_hint">dialog</property> - <child> - <placeholder/> - </child> + <property name="can-focus">False</property> + <property name="type-hint">dialog</property> <child internal-child="vbox"> <object class="GtkBox"> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="orientation">vertical</property> <property name="spacing">2</property> <child internal-child="action_area"> <object class="GtkButtonBox"> - <property name="can_focus">False</property> - <property name="layout_style">end</property> + <property name="can-focus">False</property> + <property name="layout-style">end</property> <child> <object class="GtkButton" id="button_unlock_cancel"> <property name="label" translatable="yes">Cancel</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="margin_right">6</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> </object> <packing> <property name="expand">True</property> @@ -59,10 +55,10 @@ Author: Antenore Gatta <object class="GtkButton" id="button_unlock"> <property name="label" translatable="yes">Unlock</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">True</property> - <property name="margin_left">6</property> + <property name="can-focus">True</property> + <property name="can-default">True</property> + <property name="receives-default">True</property> + <property name="margin-start">6</property> </object> <packing> <property name="expand">True</property> @@ -78,69 +74,72 @@ Author: Antenore Gatta </packing> </child> <child> - <object class="GtkGrid"> + <object class="GtkBox"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="vexpand">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> <child> - <object class="GtkLabel"> + <object class="GtkHeaderBar"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="margin_left">18</property> - <property name="margin_right">18</property> - <property name="margin_top">18</property> - <property name="margin_bottom">9</property> - <property name="hexpand">True</property> - <property name="label" translatable="yes">Unlock Remmina</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> + <property name="can-focus">False</property> + <property name="title" translatable="yes">Unlock Remmina</property> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="width">3</property> - </packing> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="halign">end</property> - <property name="valign">center</property> - <property name="margin_left">12</property> - <property name="margin_right">6</property> - <property name="margin_top">9</property> - <property name="margin_bottom">18</property> - <property name="hexpand">True</property> - <property name="label" translatable="yes">Password</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> </packing> </child> <child> - <object class="GtkEntry" id="entry_unlock"> + <!-- n-columns=2 n-rows=1 --> + <object class="GtkGrid"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="has_focus">True</property> - <property name="tooltip_text" translatable="yes">Master password</property> - <property name="halign">start</property> - <property name="valign">center</property> - <property name="margin_left">6</property> - <property name="margin_right">18</property> - <property name="margin_top">9</property> - <property name="margin_bottom">18</property> - <property name="hexpand">True</property> - <property name="visibility">False</property> - <property name="invisible_char">•</property> - <property name="input_purpose">password</property> + <property name="can-focus">False</property> + <property name="vexpand">True</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">end</property> + <property name="valign">center</property> + <property name="margin-start">18</property> + <property name="margin-end">6</property> + <property name="margin-top">9</property> + <property name="margin-bottom">18</property> + <property name="label" translatable="yes">Password</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="entry_unlock"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="tooltip-text" translatable="yes">Master password</property> + <property name="halign">start</property> + <property name="valign">center</property> + <property name="margin-start">6</property> + <property name="margin-end">18</property> + <property name="margin-top">9</property> + <property name="margin-bottom">18</property> + <property name="hexpand">True</property> + <property name="visibility">False</property> + <property name="invisible-char">•</property> + <property name="width-chars">28</property> + <property name="input-purpose">password</property> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">0</property> + </packing> + </child> </object> <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - <property name="width">2</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> </packing> </child> </object> diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e85f252d7..5d3439832 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -79,6 +79,8 @@ list( "remmina_plugin_native.h" "remmina_ext_exec.c" "remmina_ext_exec.h" + "remmina_passwd.c" + "remmina_passwd.h" "remmina_pref.c" "remmina_pref_dialog.c" "remmina_pref_dialog.h" @@ -131,6 +133,7 @@ set(RESOURCE_LIST ${CMAKE_CURRENT_SOURCE_DIR}/../data/ui/remmina_main.glade ${CMAKE_CURRENT_SOURCE_DIR}/../data/ui/remmina_mpc.glade ${CMAKE_CURRENT_SOURCE_DIR}/../data/ui/remmina_news.glade + ${CMAKE_CURRENT_SOURCE_DIR}/../data/ui/remmina_passwd.glade ${CMAKE_CURRENT_SOURCE_DIR}/../data/ui/remmina_preferences.glade ${CMAKE_CURRENT_SOURCE_DIR}/../data/ui/remmina_search.glade ${CMAKE_CURRENT_SOURCE_DIR}/../data/ui/remmina_search_popover.glade diff --git a/src/remmina_pref.c b/src/remmina_pref.c index 330770125..a00b20751 100644 --- a/src/remmina_pref.c +++ b/src/remmina_pref.c @@ -1103,17 +1103,24 @@ void remmina_pref_set_value(const gchar *key, const gchar *value) { TRACE_CALL(__func__); GKeyFile *gkeyfile; - gchar *content; gsize length; gkeyfile = g_key_file_new(); - g_key_file_load_from_file(gkeyfile, remmina_pref_file, G_KEY_FILE_NONE, NULL); - g_key_file_set_string(gkeyfile, "remmina_pref", key, value); - content = g_key_file_to_data(gkeyfile, &length, NULL); - g_file_set_contents(remmina_pref_file, content, length, NULL); + if (g_key_file_load_from_file(gkeyfile, remmina_pref_file, G_KEY_FILE_NONE, NULL)) + { + g_key_file_set_string(gkeyfile, "remmina_pref", key, value); + gchar *content = g_key_file_to_data(gkeyfile, &length, NULL); + if (g_file_set_contents(remmina_pref_file, content, length, NULL)) { + g_free(content); + } else { + REMMINA_WARNING ("Cannot save Remmina preferences"); + REMMINA_WARNING ("Key was \"%s\", and value \"%s\"", key, value); - g_key_file_free(gkeyfile); - g_free(content); + } + g_key_file_free(gkeyfile); + } else { + REMMINA_WARNING ("Cannot load Remmina preferences file"); + } } gchar *remmina_pref_get_value(const gchar *key) diff --git a/src/remmina_unlock.c b/src/remmina_unlock.c index 797ec6d4c..10f1dac0a 100644 --- a/src/remmina_unlock.c +++ b/src/remmina_unlock.c @@ -44,6 +44,7 @@ #include "remmina_pref.h" #include "remmina_log.h" #include "remmina_unlock.h" +#include "remmina_passwd.h" #include "remmina_public.h" #include "remmina/remmina_trace_calls.h" @@ -89,7 +90,7 @@ static void remmina_unlock_unlock_clicked(GtkButton *btn, gpointer user_data) unlock_password = remmina_pref_get_value("unlock_password"); entry_passwd = gtk_entry_get_text(remmina_unlock_dialog->entry_unlock); rc = remmina_sodium_pwhash_str_verify(unlock_password, entry_passwd); - REMMINA_DEBUG("remmina_sodium_pwhash_str_verify returned %i", rc); + //REMMINA_DEBUG("remmina_sodium_pwhash_str_verify returned %i", rc); if (rc == 0) { REMMINA_DEBUG("Passphrase veryfied successfully"); @@ -97,7 +98,7 @@ static void remmina_unlock_unlock_clicked(GtkButton *btn, gpointer user_data) gtk_widget_destroy(GTK_WIDGET(remmina_unlock_dialog->dialog)); remmina_unlock_dialog->dialog = NULL; } else { - g_warning ("Passphrase is wrong, to reset it, you can edit the remmina.pref file by hand"); + REMMINA_WARNING ("Passphrase is wrong, to reset it, you can edit the remmina.pref file by hand"); } } @@ -166,9 +167,17 @@ gint remmina_unlock_new(GtkWindow *parent) gtk_builder_connect_signals(remmina_unlock_dialog->builder, NULL); //if (remmina_pref_get_boolean("use_primary_password") - if ((g_strcmp0(remmina_pref_get_value("unlock_password"), "") != 0) - && lock != 0) + gchar *unlock_password = NULL; + unlock_password = remmina_pref_get_value("unlock_password"); + if ((unlock_password == NULL) || (g_strcmp0(unlock_password, "") == 0)) { + remmina_passwd (GTK_WINDOW(remmina_unlock_dialog->dialog), &unlock_password); + //REMMINA_DEBUG ("Password is: %s", unlock_password); + remmina_pref_set_value("unlock_password", g_strdup(unlock_password)); + } + if ((g_strcmp0(unlock_password, "") != 0) && lock != 0) gtk_dialog_run(remmina_unlock_dialog->dialog); + + g_free(unlock_password), unlock_password = NULL; return(remmina_unlock_dialog->retval); } |