Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/Remmina/Remmina.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAntenore Gatta (tmow) <antenore@simbiosi.org>2022-01-10 02:59:07 +0300
committerAntenore Gatta (tmow) <antenore@simbiosi.org>2022-01-10 02:59:07 +0300
commit4d6dab084a89b51ba2aa25efc415ad0a716bc072 (patch)
treee7d22baf4b957577670cfc4d4087e77974988eaf /src
parent8abc84c821bb96d6cca878028d1c02e63e5bf7e2 (diff)
Primary Password dialog and hardening
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/remmina_pref.c21
-rw-r--r--src/remmina_unlock.c17
3 files changed, 30 insertions, 11 deletions
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);
}