diff options
author | Antenore Gatta <antenore@simbiosi.org> | 2020-11-26 15:43:16 +0300 |
---|---|---|
committer | Antenore Gatta <antenore@simbiosi.org> | 2020-11-26 15:43:16 +0300 |
commit | 3d66abc80c423794f38d279aefaf30cb5fd5f8c6 (patch) | |
tree | 71a9d7cbb18a1b03b599319b9320371ba781ab2f /src | |
parent | b1860040fa4c6ad98fcba9ba8c2ab017f417179c (diff) |
Automatically accept changes to fingerprints and certificates
Signed-off-by: Antenore Gatta <antenore@simbiosi.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/remmina_main.c | 31 | ||||
-rw-r--r-- | src/remmina_pref.c | 5 | ||||
-rw-r--r-- | src/remmina_pref.h | 10 | ||||
-rw-r--r-- | src/remmina_pref_dialog.c | 3 | ||||
-rw-r--r-- | src/remmina_pref_dialog.h | 1 | ||||
-rw-r--r-- | src/remmina_protocol_widget.c | 12 | ||||
-rw-r--r-- | src/remmina_public.c | 21 |
7 files changed, 66 insertions, 17 deletions
diff --git a/src/remmina_main.c b/src/remmina_main.c index fef677fc7..ed692e4b7 100644 --- a/src/remmina_main.c +++ b/src/remmina_main.c @@ -88,25 +88,28 @@ const gchar *supported_mime_types[] = { NULL }; -static GActionEntry main_actions[] = { +static GActionEntry app_actions[] = { { "about", remmina_main_on_action_application_about, NULL, NULL, NULL }, { "news", remmina_main_on_action_application_news, NULL, NULL, NULL }, { "default", remmina_main_on_action_application_default, NULL, NULL, NULL }, { "mpchange", remmina_main_on_action_application_mpchange, NULL, NULL, NULL }, { "plugins", remmina_main_on_action_application_plugins, NULL, NULL, NULL }, - { "preferences", remmina_main_on_action_application_preferences, NULL, NULL, NULL }, + { "preferences", remmina_main_on_action_application_preferences, "i", NULL, NULL }, { "quit", remmina_main_on_action_application_quit, NULL, NULL, NULL }, + { "debug", remmina_main_on_action_help_debug, NULL, NULL, NULL }, + { "community", remmina_main_on_action_help_community, NULL, NULL, NULL }, + { "donations", remmina_main_on_action_help_donations, NULL, NULL, NULL }, + { "homepage", remmina_main_on_action_help_homepage, NULL, NULL, NULL }, + { "wiki", remmina_main_on_action_help_wiki, NULL, NULL, NULL }, +}; + +static GActionEntry main_actions[] = { { "connect", remmina_main_on_action_connection_connect, NULL, NULL, NULL }, { "copy", remmina_main_on_action_connection_copy, NULL, NULL, NULL }, { "delete", remmina_main_on_action_connection_delete, NULL, NULL, NULL }, { "edit", remmina_main_on_action_connection_edit, NULL, NULL, NULL }, { "exttools", remmina_main_on_action_connection_external_tools, NULL, NULL, NULL }, { "new", remmina_main_on_action_connection_new, NULL, NULL, NULL }, - { "community", remmina_main_on_action_help_community, NULL, NULL, NULL }, - { "debug", remmina_main_on_action_help_debug, NULL, NULL, NULL }, - { "donations", remmina_main_on_action_help_donations, NULL, NULL, NULL }, - { "homepage", remmina_main_on_action_help_homepage, NULL, NULL, NULL }, - { "wiki", remmina_main_on_action_help_wiki, NULL, NULL, NULL }, { "export", remmina_main_on_action_tools_export, NULL, NULL, NULL }, { "import", remmina_main_on_action_tools_import, NULL, NULL, NULL }, { "expand", remmina_main_on_action_expand, NULL, NULL, NULL }, @@ -847,9 +850,19 @@ void remmina_main_on_action_connection_delete(GSimpleAction *action, GVariant *p void remmina_main_on_action_application_preferences(GSimpleAction *action, GVariant *param, gpointer data) { TRACE_CALL(__func__); + + REMMINA_DEBUG ("Opening the preferences"); + gint32 tab_num; + if (param) { + REMMINA_DEBUG ("Parameter passed to preferences of type %s", g_variant_get_type_string(param)); + tab_num = g_variant_get_int32 (param); + REMMINA_DEBUG ("We got a parameter for the preferences: %d", tab_num); + } else + tab_num = 0; + if (remmina_unlock_new(remminamain->window) == 0) return; - GtkDialog *dialog = remmina_pref_dialog_new(0, remminamain->window); + GtkDialog *dialog = remmina_pref_dialog_new(tab_num, remminamain->window); gtk_dialog_run(dialog); gtk_widget_destroy(GTK_WIDGET(dialog)); } @@ -1362,6 +1375,8 @@ GtkWidget *remmina_main_new(void) remminamain->statusbar_main = GTK_STATUSBAR(RM_GET_OBJECT("statusbar_main")); /* Non widget objects */ actions = g_simple_action_group_new(); + g_action_map_add_action_entries(G_ACTION_MAP(actions), app_actions, G_N_ELEMENTS(app_actions), remminamain->window); + gtk_widget_insert_action_group(GTK_WIDGET(remminamain->window), "app", G_ACTION_GROUP(actions)); g_action_map_add_action_entries(G_ACTION_MAP(actions), main_actions, G_N_ELEMENTS(main_actions), remminamain->window); gtk_widget_insert_action_group(GTK_WIDGET(remminamain->window), "main", G_ACTION_GROUP(actions)); g_object_unref(actions); diff --git a/src/remmina_pref.c b/src/remmina_pref.c index 080b04c31..5ca685c5b 100644 --- a/src/remmina_pref.c +++ b/src/remmina_pref.c @@ -296,6 +296,10 @@ void remmina_pref_init(void) else remmina_pref.unlock_password = g_strdup(""); + if (g_key_file_has_key(gkeyfile, "remmina_pref", "trust_all", NULL)) + remmina_pref.trust_all = g_key_file_get_boolean(gkeyfile, "remmina_pref", "trust_all", NULL); + else + remmina_pref.trust_all = FALSE; if (g_key_file_has_key(gkeyfile, "remmina_pref", "fullscreen_on_auto", NULL)) remmina_pref.fullscreen_on_auto = g_key_file_get_boolean(gkeyfile, "remmina_pref", "fullscreen_on_auto", NULL); @@ -762,6 +766,7 @@ gboolean remmina_pref_save(void) g_key_file_set_integer(gkeyfile, "remmina_pref", "unlock_timeout", 0); g_key_file_set_string(gkeyfile, "remmina_pref", "unlock_password", g_strdup("")); #endif + g_key_file_set_boolean(gkeyfile, "remmina_pref", "trust_all", remmina_pref.trust_all); g_key_file_set_integer(gkeyfile, "remmina_pref", "floating_toolbar_placement", remmina_pref.floating_toolbar_placement); g_key_file_set_integer(gkeyfile, "remmina_pref", "toolbar_placement", remmina_pref.toolbar_placement); g_key_file_set_boolean(gkeyfile, "remmina_pref", "prevent_snap_welcome_message", remmina_pref.prevent_snap_welcome_message); diff --git a/src/remmina_pref.h b/src/remmina_pref.h index e13f2db81..fbc0cf523 100644 --- a/src/remmina_pref.h +++ b/src/remmina_pref.h @@ -116,10 +116,6 @@ typedef struct _RemminaPref { gboolean deny_screenshot_clipboard; const gchar * screenshot_name; gboolean save_view_mode; - gboolean use_master_password; - const gchar * unlock_password; - const gchar * unlock_repassword; - gint unlock_timeout; gint default_action; gint scale_quality; gint auto_scroll_step; @@ -161,6 +157,12 @@ typedef struct _RemminaPref { guint shortcutkey_minimize; guint shortcutkey_disconnect; guint shortcutkey_toolbar; + /* In RemminaPrefDialog security tab */ + gboolean use_master_password; + const gchar * unlock_password; + const gchar * unlock_repassword; + gint unlock_timeout; + gboolean trust_all; /* In RemminaPrefDialog terminal tab */ gchar * vte_font; gboolean vte_allow_bold_text; diff --git a/src/remmina_pref_dialog.c b/src/remmina_pref_dialog.c index d08864477..f102a873b 100644 --- a/src/remmina_pref_dialog.c +++ b/src/remmina_pref_dialog.c @@ -212,6 +212,7 @@ void remmina_pref_on_dialog_destroy(GtkWidget *widget, gpointer user_data) 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.trust_all = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_security_trust_all)); remmina_pref.screenshot_path = gtk_file_chooser_get_filename(remmina_pref_dialog->filechooserbutton_options_screenshots_path); remmina_pref.fullscreen_on_auto = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(remmina_pref_dialog->checkbutton_appearance_fullscreen_on_auto)); remmina_pref.always_show_tab = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(remmina_pref_dialog->checkbutton_appearance_show_tabs)); @@ -450,6 +451,7 @@ static void remmina_pref_dialog_init(void) gtk_widget_set_sensitive(GTK_WIDGET(remmina_pref_dialog->unlock_repassword), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(remmina_pref_dialog->unlock_timeout), FALSE); #endif + gtk_switch_set_active(GTK_SWITCH(remmina_pref_dialog->switch_security_trust_all), remmina_pref.trust_all); gtk_switch_set_active(GTK_SWITCH(remmina_pref_dialog->switch_options_deny_screenshot_clipboard), remmina_pref.deny_screenshot_clipboard); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(remmina_pref_dialog->checkbutton_appearance_fullscreen_on_auto), remmina_pref.fullscreen_on_auto); @@ -642,6 +644,7 @@ GtkDialog* remmina_pref_dialog_new(gint default_tab, GtkWindow *parent) remmina_pref_dialog->switch_security_use_master_password = GTK_SWITCH(GET_OBJECT("switch_security_use_master_password")); 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_trust_all = GTK_SWITCH(GET_OBJECT("switch_security_trust_all")); remmina_pref_dialog->checkbutton_options_save_settings = GTK_CHECK_BUTTON(GET_OBJECT("checkbutton_options_save_settings")); remmina_pref_dialog->checkbutton_appearance_fullscreen_on_auto = GTK_CHECK_BUTTON(GET_OBJECT("checkbutton_appearance_fullscreen_on_auto")); remmina_pref_dialog->checkbutton_appearance_show_tabs = GTK_CHECK_BUTTON(GET_OBJECT("checkbutton_appearance_show_tabs")); diff --git a/src/remmina_pref_dialog.h b/src/remmina_pref_dialog.h index 2fc2a3cd8..b9ef7e36d 100644 --- a/src/remmina_pref_dialog.h +++ b/src/remmina_pref_dialog.h @@ -58,6 +58,7 @@ typedef struct _RemminaPrefDialog { GtkEntry * unlock_timeout; GtkEntry * unlock_password; GtkEntry * unlock_repassword; + GtkSwitch * switch_security_trust_all; GtkCheckButton * checkbutton_options_save_settings; GtkCheckButton * checkbutton_appearance_fullscreen_on_auto; GtkCheckButton * checkbutton_appearance_show_tabs; diff --git a/src/remmina_protocol_widget.c b/src/remmina_protocol_widget.c index ac3724d02..d595df1fb 100644 --- a/src/remmina_protocol_widget.c +++ b/src/remmina_protocol_widget.c @@ -1494,6 +1494,12 @@ gint remmina_protocol_widget_panel_new_certificate(RemminaProtocolWidget *gp, co gchar *s; int rc; + if (remmina_pref_get_boolean("trust_all")) { + /* For compatibility with plugin API: The plugin expects GTK_RESPONSE_OK when user confirms new cert */ + remmina_public_send_notification("remmina-security-trust-all-id", _("Fingerprint automatically accepted"), fingerprint); + rc = GTK_RESPONSE_OK; + return rc; + } // For markup see https://developer.gnome.org/pygtk/stable/pango-markup-language.html s = g_strdup_printf( "<big>%s</big>\n\n%s %s\n%s %s\n%s %s\n\n<big>%s</big>", @@ -1515,6 +1521,12 @@ gint remmina_protocol_widget_panel_changed_certificate(RemminaProtocolWidget *gp gchar *s; int rc; + if (remmina_pref_get_boolean("trust_all")) { + /* For compatibility with plugin API: The plugin expects GTK_RESPONSE_OK when user confirms new cert */ + remmina_public_send_notification("remmina-security-trust-all-id", _("Fingerprint automatically accepted"), new_fingerprint); + rc = GTK_RESPONSE_OK; + return rc; + } // For markup see https://developer.gnome.org/pygtk/stable/pango-markup-language.html s = g_strdup_printf( "<big>%s</big>\n\n%s %s\n%s %s\n%s %s\n%s %s\n\n<big>%s</big>", diff --git a/src/remmina_public.c b/src/remmina_public.c index 3e17450a9..cd55d5c57 100644 --- a/src/remmina_public.c +++ b/src/remmina_public.c @@ -646,13 +646,24 @@ void remmina_public_send_notification(const gchar *notification_id, { TRACE_CALL(__func__); - GNotification *notification = g_notification_new(notification_title); - g_notification_set_body(notification, notification_message); + g_autoptr(GNotification) n = NULL; + gint priority = G_NOTIFICATION_PRIORITY_NORMAL; + + n = g_notification_new(notification_title); + g_notification_set_body(n, notification_message); + if (g_strcmp0 (notification_id, "remmina-security-trust-all-id") == 0) { + g_debug ("remmina_public_send_notification: We got a remmina-security-trust-all-id notification"); + priority = G_NOTIFICATION_PRIORITY_HIGH; + /** parameter 5 is the tab index for the security tab in the preferences + * TODO: Do not hardcode the parameter + * TODO: Do not hardcode implement DBus interface correctly of this won't work*/ + g_notification_set_default_action_and_target (n, "app.preferences", "i", 5); + g_notification_add_button_with_target (n, _("Change security settings"), "app.preferences", "i", 5); + } #if GLIB_CHECK_VERSION(2, 42, 0) - g_notification_set_priority(notification, G_NOTIFICATION_PRIORITY_NORMAL); + g_notification_set_priority(n, priority); #endif - g_application_send_notification(g_application_get_default(), notification_id, notification); - g_object_unref(notification); + g_application_send_notification(g_application_get_default(), notification_id, n); } /* Replaces all occurrences of search in a new copy of string by replacement. */ |