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-15 02:32:16 +0300
committerAntenore Gatta (tmow) <antenore@simbiosi.org>2022-01-15 02:32:16 +0300
commit1a1d23cf533c0964967928ec9a1352ae328fe2e1 (patch)
tree02e40431262d39b6888811b3b23bbd892779604c /src
parent9f0784aad43a1ea42ca511407516ac10c1c83241 (diff)
Refactoring security tab, solves #2676
Diffstat (limited to 'src')
-rw-r--r--src/remmina_file.c1
-rw-r--r--src/remmina_pref.c2
-rw-r--r--src/remmina_pref.h1
-rw-r--r--src/remmina_pref_dialog.c72
-rw-r--r--src/remmina_pref_dialog.h2
-rw-r--r--src/remmina_unlock.c2
6 files changed, 29 insertions, 51 deletions
diff --git a/src/remmina_file.c b/src/remmina_file.c
index b27056ab3..9dc38a516 100644
--- a/src/remmina_file.c
+++ b/src/remmina_file.c
@@ -349,7 +349,6 @@ remmina_file_load(const gchar *filename)
GKeyFile *gkeyfile;
RemminaFile *remminafile;
gchar *key;
- gint i;
gchar *s;
RemminaProtocolPlugin *protocol_plugin;
RemminaSecretPlugin *secret_plugin;
diff --git a/src/remmina_pref.c b/src/remmina_pref.c
index acf2eb694..845f69097 100644
--- a/src/remmina_pref.c
+++ b/src/remmina_pref.c
@@ -313,7 +313,7 @@ void remmina_pref_init(void)
if (g_key_file_has_key(gkeyfile, "remmina_pref", "enc_mode", NULL))
remmina_pref.enc_mode = g_key_file_get_integer(gkeyfile, "remmina_pref", "enc_mode", NULL);
else
- remmina_pref.enc_mode = 0;
+ remmina_pref.enc_mode = 1;
if (g_key_file_has_key(gkeyfile, "remmina_pref", "audit", NULL))
remmina_pref.audit = g_key_file_get_boolean(gkeyfile, "remmina_pref", "audit", NULL);
diff --git a/src/remmina_pref.h b/src/remmina_pref.h
index 198197b80..7e90d01b9 100644
--- a/src/remmina_pref.h
+++ b/src/remmina_pref.h
@@ -86,6 +86,7 @@ enum {
REMMINA_TAB_NONE = 3
};
+/* Remember to add the id 0, 4 and 5 in the remmina pref editor */
enum {
RM_ENC_MODE_SECRET = 0, /* Using libsecret */
RM_ENC_MODE_SODIUM_INTERACTIVE = 1, /* Using libsodium */
diff --git a/src/remmina_pref_dialog.c b/src/remmina_pref_dialog.c
index 3a2f7d385..bfb7b9390 100644
--- a/src/remmina_pref_dialog.c
+++ b/src/remmina_pref_dialog.c
@@ -44,6 +44,7 @@
#include "remmina_log.h"
#include "remmina_file_manager.h"
#include "remmina_sodium.h"
+#include "remmina_passwd.h"
#include "remmina_public.h"
#include "remmina_string_list.h"
#include "remmina_widget_pool.h"
@@ -167,40 +168,32 @@ void remmina_prefdiag_on_grab_color_activated(GtkSwitch *widget, gpointer user_d
gtk_widget_set_sensitive(GTK_WIDGET(remmina_pref_dialog->entry_grab_color), gtk_switch_get_active(widget));
}
-
-void remmina_prefdiag_unlock_repwd_on_changed(GtkEditable *editable, RemminaPrefDialog *dialog)
+/* connect to notify::active or toggled (in this case ::toggled */
+void remmina_prefdiag_on_use_password_activated(GtkSwitch *sw, gpointer user_data)
{
TRACE_CALL(__func__);
- GtkCssProvider *provider;
- const gchar *color;
- const gchar *password;
- const gchar *repassword;
-
- provider = gtk_css_provider_new();
-
- password = gtk_entry_get_text(remmina_pref_dialog->unlock_password);
- repassword = gtk_entry_get_text(remmina_pref_dialog->unlock_repassword);
- if (g_strcmp0(password, repassword) == 0)
- color = g_strdup("green");
- else
- color = g_strdup("red");
-
- if (repassword == NULL || repassword[0] == '\0')
- color = g_strdup("inherit");
-
- gtk_css_provider_load_from_data(provider,
- g_strdup_printf(
- ".unlock_repassword {\n"
- " color: %s;\n"
- "}\n"
- , color)
- , -1, NULL);
- gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
- GTK_STYLE_PROVIDER(provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-
- gtk_widget_queue_draw(GTK_WIDGET(remmina_pref_dialog->unlock_repassword));
- g_object_unref(provider);
+ //REMMINA_DEBUG ("Use Primary Password %d", gtk_switch_get_active(sw));
+ if (gtk_switch_get_active(sw)) {
+ //REMMINA_DEBUG ("use_password activated");
+ gchar *unlock_password = NULL;
+ unlock_password = g_strdup(remmina_pref_get_value("unlock_password"));
+ //REMMINA_DEBUG ("Password from preferences is: %s", unlock_password);
+ if (unlock_password == NULL || unlock_password[0] == '\0') {
+ if (remmina_passwd (GTK_WINDOW(remmina_pref_dialog->dialog), &unlock_password)) {
+ //REMMINA_DEBUG ("Password is: %s", unlock_password);
+ remmina_pref_set_value("unlock_password", g_strdup(unlock_password));
+ remmina_pref.unlock_password = g_strdup(unlock_password);
+ } else {
+ remmina_pref.unlock_password = "";
+ remmina_pref_set_value("unlock_password", "");
+ }
+ }
+ g_free(unlock_password), unlock_password = NULL;
+ } else {
+ //REMMINA_DEBUG ("use_password deactivated");
+ remmina_pref.unlock_password = "";
+ remmina_pref_set_value("unlock_password", "");
+ }
}
void remmina_pref_dialog_on_action_close(GSimpleAction *action, GVariant *param, gpointer data)
@@ -234,11 +227,6 @@ void remmina_pref_on_dialog_destroy(GtkWidget *widget, gpointer user_data)
remmina_pref.deny_screenshot_clipboard = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_options_deny_screenshot_clipboard));
remmina_pref.save_view_mode = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_options_remember_last_view_mode));
remmina_pref.use_primary_password = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_security_use_primary_password));
-#if SODIUM_VERSION_INT >= 90200
- remmina_pref.unlock_repassword = gtk_entry_get_text(remmina_pref_dialog->unlock_repassword);
- if (gtk_entry_get_text_length(remmina_pref_dialog->unlock_repassword) != 0)
- remmina_pref.unlock_password = remmina_sodium_pwhash_str(gtk_entry_get_text(remmina_pref_dialog->unlock_password));
-#endif
remmina_pref.lock_connect = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_security_lock_connect));
remmina_pref.lock_edit = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_security_lock_edit));
remmina_pref.enc_mode = gtk_combo_box_get_active(remmina_pref_dialog->comboboxtext_security_enc_method);
@@ -471,13 +459,7 @@ static void remmina_pref_dialog_init(void)
gtk_switch_set_active(GTK_SWITCH(remmina_pref_dialog->switch_options_remember_last_view_mode), remmina_pref.save_view_mode);
#if SODIUM_VERSION_INT >= 90200
gtk_switch_set_active(GTK_SWITCH(remmina_pref_dialog->switch_security_use_primary_password), remmina_pref.use_primary_password);
- if (remmina_pref.unlock_password != NULL)
- gtk_entry_set_text(remmina_pref_dialog->unlock_password, remmina_pref.unlock_password);
- else
- gtk_entry_set_text(remmina_pref_dialog->unlock_password, "");
gtk_widget_set_sensitive(GTK_WIDGET(remmina_pref_dialog->switch_security_use_primary_password), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(remmina_pref_dialog->unlock_password), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(remmina_pref_dialog->unlock_repassword), TRUE);
gtk_switch_set_active(GTK_SWITCH(remmina_pref_dialog->switch_security_lock_connect), remmina_pref.lock_connect);
gtk_switch_set_active(GTK_SWITCH(remmina_pref_dialog->switch_security_lock_edit), remmina_pref.lock_edit);
gtk_widget_set_sensitive(GTK_WIDGET(remmina_pref_dialog->unlock_timeout), TRUE);
@@ -486,8 +468,6 @@ static void remmina_pref_dialog_init(void)
gtk_widget_set_sensitive(GTK_WIDGET(remmina_pref_dialog->switch_security_use_primary_password), FALSE);
// TRANSLATORS: Do not translate libsodium, is the name of a library
gtk_widget_set_tooltip_text(GTK_WIDGET(remmina_pref_dialog->switch_security_use_primary_password), _("libsodium >= 1.9.0 is required to use Primary Password"));
- gtk_widget_set_sensitive(GTK_WIDGET(remmina_pref_dialog->unlock_password), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(remmina_pref_dialog->unlock_repassword), FALSE);
gtk_switch_set_active(GTK_SWITCH(remmina_pref_dialog->switch_security_lock_connect), FALSE);
gtk_switch_set_active(GTK_SWITCH(remmina_pref_dialog->switch_security_lock_edit), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(remmina_pref_dialog->unlock_timeout), FALSE);
@@ -724,8 +704,6 @@ GtkWidget *remmina_pref_dialog_new(gint default_tab, GtkWindow *parent)
remmina_pref_dialog->switch_options_remember_last_view_mode = GTK_SWITCH(GET_OBJECT("switch_options_remember_last_view_mode"));
remmina_pref_dialog->switch_security_use_primary_password = GTK_SWITCH(GET_OBJECT("switch_security_use_primary_password"));
remmina_pref_dialog->unlock_timeout = GTK_ENTRY(GET_OBJECT("unlock_timeout"));
- remmina_pref_dialog->unlock_password = GTK_ENTRY(GET_OBJECT("unlock_password"));
- remmina_pref_dialog->unlock_repassword = GTK_ENTRY(GET_OBJECT("unlock_repassword"));
remmina_pref_dialog->switch_security_lock_connect = GTK_SWITCH(GET_OBJECT("switch_security_lock_connect"));
remmina_pref_dialog->switch_security_lock_edit = GTK_SWITCH(GET_OBJECT("switch_security_lock_edit"));
remmina_pref_dialog->comboboxtext_security_enc_method = GTK_COMBO_BOX(GET_OBJECT("comboboxtext_security_enc_method"));
diff --git a/src/remmina_pref_dialog.h b/src/remmina_pref_dialog.h
index 583fdd864..346a8f9d0 100644
--- a/src/remmina_pref_dialog.h
+++ b/src/remmina_pref_dialog.h
@@ -58,8 +58,6 @@ typedef struct _RemminaPrefDialog {
GtkSwitch * switch_options_remember_last_view_mode;
GtkSwitch * switch_security_use_primary_password;
GtkEntry * unlock_timeout;
- GtkEntry * unlock_password;
- GtkEntry * unlock_repassword;
GtkSwitch * switch_security_lock_connect;
GtkSwitch * switch_security_lock_edit;
GtkSwitch * switch_security_audit;
diff --git a/src/remmina_unlock.c b/src/remmina_unlock.c
index dcdc15d8f..8e878ae32 100644
--- a/src/remmina_unlock.c
+++ b/src/remmina_unlock.c
@@ -180,6 +180,8 @@ gint remmina_unlock_new(GtkWindow *parent)
/* Connect signals */
gtk_builder_connect_signals(remmina_unlock_dialog->builder, NULL);
+ g_object_set_data_full (G_OBJECT(remmina_unlock_dialog->dialog), "builder", remmina_unlock_dialog->builder, g_object_unref);
+
gchar *unlock_password = NULL;
unlock_password = g_strdup(remmina_pref_get_value("unlock_password"));
//REMMINA_DEBUG ("Password from preferences is: %s", unlock_password);