Skip to content

Commit

Permalink
Merge pull request #1196 from FreeRDP/ssh-improvements
Browse files Browse the repository at this point in the history
Ssh improvements. Closes #708 , closes #1078 , closes #1187
  • Loading branch information
antenore authored Jun 19, 2017
2 parents fa8bd2f + 2871aef commit fbf619a
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 79 deletions.
8 changes: 7 additions & 1 deletion remmina/src/remmina_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ static const RemminaProtocolSetting* find_protocol_setting(const gchar *name, Re

static gboolean is_encrypted_setting(const RemminaProtocolSetting* setting)
{
TRACE_CALL("is_encrypted_setting");
if (setting != NULL &&
(setting->type == REMMINA_PROTOCOL_SETTING_TYPE_PASSWORD) )
{
Expand All @@ -187,9 +188,14 @@ static gboolean is_encrypted_setting(const RemminaProtocolSetting* setting)

static gboolean is_encrypted_setting_by_name(const gchar *setting_name, RemminaProtocolPlugin* protocol_plugin)
{
TRACE_CALL("is_encrypted_setting");
TRACE_CALL("is_encrypted_setting_by_name");
const RemminaProtocolSetting* setting;

if (strcmp(setting_name, "ssh_password") == 0)
{
return TRUE;
}

setting = find_protocol_setting(setting_name, protocol_plugin);
return is_encrypted_setting(setting);
}
Expand Down
90 changes: 45 additions & 45 deletions remmina/src/remmina_file_editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,24 @@ static void remmina_file_editor_ssh_auth_publickey_radio_on_toggled(GtkToggleBut
}
}

static void remmina_file_editor_ssh_enabled_check_on_toggled(GtkToggleButton* togglebutton, RemminaFileEditor* gfe)
static void remmina_file_editor_ssh_enabled_check_on_toggled(GtkToggleButton* togglebutton,
RemminaFileEditor* gfe, RemminaProtocolSSHSetting ssh_setting)
{
TRACE_CALL("remmina_file_editor_ssh_enabled_check_on_toggled");
gboolean enabled = TRUE;

if (gfe->priv->ssh_enabled_check)
{
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gfe->priv->ssh_enabled_check));
if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_SSH ||
ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_SFTP)
{
gtk_widget_set_sensitive(gfe->priv->ssh_enabled_check, 1);
gtk_widget_set_sensitive(gfe->priv->ssh_loopback_check, 1);
}
else
{
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gfe->priv->ssh_enabled_check));
}
if (gfe->priv->ssh_loopback_check)
gtk_widget_set_sensitive(gfe->priv->ssh_loopback_check, enabled);
if (gfe->priv->ssh_server_default_radio)
Expand All @@ -316,6 +326,7 @@ static void remmina_file_editor_ssh_enabled_check_on_toggled(GtkToggleButton* to
}
remmina_file_editor_ssh_auth_publickey_radio_on_toggled(NULL, gfe);

if (gfe->priv->ssh_username_entry)
if (enabled && gtk_entry_get_text(GTK_ENTRY(gfe->priv->ssh_username_entry)) [0] == '\0')
{
gtk_entry_set_text(GTK_ENTRY(gfe->priv->ssh_username_entry), g_get_user_name());
Expand Down Expand Up @@ -388,6 +399,7 @@ static void remmina_file_editor_create_server(RemminaFileEditor* gfe, const Remm

s = remmina_pref_get_recent(plugin->name);
widget = remmina_public_create_combo_entry(s, remmina_file_get_string(gfe->priv->remmina_file, "server"), TRUE);
gtk_widget_set_hexpand (widget, TRUE);
gtk_widget_show(widget);
gtk_widget_set_tooltip_markup(widget, _(server_tips));
gtk_entry_set_activates_default(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(widget))), TRUE);
Expand Down Expand Up @@ -442,6 +454,7 @@ static GtkWidget* remmina_file_editor_create_password(RemminaFileEditor* gfe, Gt
gtk_grid_attach(GTK_GRID(grid), widget, 1, row, 1, 1);
gtk_entry_set_max_length(GTK_ENTRY(widget), 100);
gtk_entry_set_visibility(GTK_ENTRY(widget), FALSE);
gtk_widget_set_hexpand (widget, TRUE);

if (value)
{
Expand Down Expand Up @@ -549,6 +562,7 @@ static GtkWidget* remmina_file_editor_create_text(RemminaFileEditor* gfe, GtkWid
gtk_widget_show(widget);
gtk_grid_attach(GTK_GRID(grid), widget, 1, row, 1, 1);
gtk_entry_set_max_length(GTK_ENTRY(widget), 300);
gtk_widget_set_hexpand (widget, TRUE);

if (value)
gtk_entry_set_text(GTK_ENTRY(widget), value);
Expand Down Expand Up @@ -776,39 +790,32 @@ static void remmina_file_editor_create_ssh_tab(RemminaFileEditor* gfe, RemminaPr
if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_NONE) return;

/* The SSH tab (implementation) */
if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_SSH ||
ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_SFTP)
{
s = remmina_public_combo_get_active_text (GTK_COMBO_BOX (priv->protocol_combo));
grid = remmina_file_editor_create_notebook_tab (gfe, "dialog-password",
(s ? s : "SSH"), 8, 3);
g_free(s);
}
else
{
grid = remmina_file_editor_create_notebook_tab (gfe, "dialog-password",
"SSH", 9, 3);
grid = remmina_file_editor_create_notebook_tab (gfe, "dialog-password",
"SSH Settings", 9, 3);

hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_show(hbox);
gtk_grid_attach (GTK_GRID(grid), hbox, 0, 0, 3, 1);
row++;
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_show(hbox);
gtk_grid_attach (GTK_GRID(grid), hbox, 0, 0, 3, 1);
row++;

if (!(ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_SSH ||
ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_SFTP))
{
widget = gtk_check_button_new_with_label (_("Enable SSH tunnel"));
gtk_widget_show(widget);
gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(widget), "toggled",
G_CALLBACK(remmina_file_editor_ssh_enabled_check_on_toggled), gfe);
G_CALLBACK(remmina_file_editor_ssh_enabled_check_on_toggled), gfe);
priv->ssh_enabled_check = widget;

widget = gtk_check_button_new_with_label (_("Tunnel via loopback address"));
gtk_widget_show(widget);
gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
priv->ssh_loopback_check = widget;
}

row++;
}
/* SSH Server group */
row++;

switch (ssh_setting)
{
Expand Down Expand Up @@ -847,20 +854,12 @@ static void remmina_file_editor_create_ssh_tab(RemminaFileEditor* gfe, RemminaPr
gtk_widget_set_tooltip_markup (priv->ssh_server_entry, _(server_tips));
row++;
break;

case REMMINA_PROTOCOL_SSH_SETTING_SSH:
case REMMINA_PROTOCOL_SSH_SETTING_SFTP:
priv->ssh_server_default_radio = NULL;
priv->ssh_server_custom_radio = NULL;
priv->ssh_server_entry = NULL;

s = remmina_pref_get_recent ("SFTP");
priv->server_combo = remmina_file_editor_create_combo (gfe, grid, row + 1, 1,
_("Server"), s, remmina_file_get_string (priv->remmina_file, "server"));
gtk_widget_set_tooltip_markup (priv->server_combo, _(server_tips));
gtk_entry_set_activates_default (GTK_ENTRY(gtk_bin_get_child (GTK_BIN (priv->server_combo))), TRUE);
g_free(s);
row++;
break;

default:
Expand Down Expand Up @@ -894,10 +893,14 @@ static void remmina_file_editor_create_ssh_tab(RemminaFileEditor* gfe, RemminaPr
remmina_public_create_group (GTK_GRID(grid), _("SSH Authentication"), row + 8, 6, 1);
row++;

priv->ssh_username_entry = remmina_file_editor_create_text (gfe, grid, row + 10, 0,
_("User name"), NULL);
row++;

if (ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_TUNNEL ||
ssh_setting == REMMINA_PROTOCOL_SSH_SETTING_REVERSE_TUNNEL)
{
priv->ssh_username_entry =
remmina_file_editor_create_text (gfe, grid, row + 10, 0,
_("User name"), NULL);
row++;
}
widget = gtk_radio_button_new_with_label (NULL, _("SSH Agent (automatic)"));
gtk_widget_show(widget);
gtk_grid_attach (GTK_GRID(grid), widget, 0, row + 19, 1, 1);
Expand Down Expand Up @@ -945,18 +948,16 @@ static void remmina_file_editor_create_ssh_tab(RemminaFileEditor* gfe, RemminaPr
cs ? cs : "");
}

cs = remmina_file_get_string (priv->remmina_file, "ssh_username");
gtk_entry_set_text(GTK_ENTRY(priv->ssh_username_entry), cs ? cs : "");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(
remmina_file_get_int (priv->remmina_file, "ssh_auth", 0) == SSH_AUTH_PUBLICKEY ?
priv->ssh_auth_publickey_radio :
remmina_file_get_int (priv->remmina_file, "ssh_auth", 0) == SSH_AUTH_AUTO_PUBLICKEY ?
priv->ssh_auth_auto_publickey_radio :
remmina_file_get_int (priv->remmina_file, "ssh_auth", 0) == SSH_AUTH_AGENT ?
priv->ssh_auth_agent_radio :
priv->ssh_auth_password_radio), TRUE);

remmina_file_editor_ssh_enabled_check_on_toggled (NULL, gfe);
remmina_file_get_int (priv->remmina_file, "ssh_auth", 0) == SSH_AUTH_PUBLICKEY ?
priv->ssh_auth_publickey_radio :
remmina_file_get_int (priv->remmina_file, "ssh_auth", 0) == SSH_AUTH_AUTO_PUBLICKEY ?
priv->ssh_auth_auto_publickey_radio :
remmina_file_get_int (priv->remmina_file, "ssh_auth", 0) == SSH_AUTH_AGENT ?
priv->ssh_auth_agent_radio :
priv->ssh_auth_password_radio), TRUE);

remmina_file_editor_ssh_enabled_check_on_toggled (NULL, gfe, ssh_setting);
#endif
}

Expand Down Expand Up @@ -1268,7 +1269,6 @@ static void remmina_file_editor_init(RemminaFileEditor* gfe)
widget = gtk_dialog_add_button(GTK_DIALOG(gfe), (_("Default")), GTK_RESPONSE_OK);
gtk_button_set_image(GTK_BUTTON(widget), gtk_image_new_from_icon_name("preferences-system", GTK_ICON_SIZE_BUTTON));
g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(remmina_file_editor_on_default), gfe);
//gtk_widget_show(widget);

priv->setting_widgets = g_hash_table_new(g_str_hash, g_str_equal);

Expand Down
7 changes: 3 additions & 4 deletions remmina/src/remmina_protocol_widget.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Remmina - The GTK+ Remote Desktop Client
* Copyright (C) 2009-2011 Vic Lee
* Copyright (C) 2014-2015 Antenore Gatta, Fabio Castelli, Giovanni Panozzo
* Copyright (C) 2016-2017 Antenore Gatta, Giovanni Panozzo
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -608,7 +609,7 @@ static gboolean remmina_protocol_widget_init_tunnel (RemminaProtocolWidget* gp)
return FALSE;
}

ret = remmina_ssh_auth_gui (REMMINA_SSH (tunnel), REMMINA_INIT_DIALOG (gp->priv->init_dialog));
ret = remmina_ssh_auth_gui (REMMINA_SSH (tunnel), REMMINA_INIT_DIALOG (gp->priv->init_dialog), gp->priv->remmina_file);
if (ret <= 0)
{
if (ret == 0)
Expand Down Expand Up @@ -998,9 +999,7 @@ gint remmina_protocol_widget_init_authpwd(RemminaProtocolWidget* gp, RemminaAuth
REMMINA_INIT_DIALOG(gp->priv->init_dialog),
s,
remmina_file_get_filename(remminafile) != NULL &&
allow_password_saving &&
authpwd_type != REMMINA_AUTHPWD_TYPE_SSH_PWD &&
authpwd_type != REMMINA_AUTHPWD_TYPE_SSH_PRIVKEY);
allow_password_saving);
g_free(s);

return ret;
Expand Down
22 changes: 20 additions & 2 deletions remmina/src/remmina_sftp_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Remmina - The GTK+ Remote Desktop Client
* Copyright (C) 2010 Vic Lee
* Copyright (C) 2014-2015 Antenore Gatta, Fabio Castelli, Giovanni Panozzo
* Copyright (C) 2016-2017 Antenore Gatta, Giovanni Panozzo
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -110,7 +111,7 @@ remmina_plugin_sftp_main_thread (gpointer data)
}

ret = remmina_ssh_auth_gui (REMMINA_SSH (sftp),
REMMINA_INIT_DIALOG (remmina_protocol_widget_get_init_dialog (gp)));
REMMINA_INIT_DIALOG (remmina_protocol_widget_get_init_dialog (gp)), remminafile);
if (ret == 0)
{
remmina_plugin_service->protocol_plugin_set_error (gp, "%s", REMMINA_SSH (sftp)->error);
Expand Down Expand Up @@ -285,6 +286,23 @@ static const RemminaProtocolFeature remmina_plugin_sftp_features[] =
{ REMMINA_PROTOCOL_FEATURE_TYPE_END, 0, NULL, NULL, NULL }
};

/* Array of RemminaProtocolSetting for basic settings.
* Each item is composed by:
* a) RemminaProtocolSettingType for setting type
* b) Setting name
* c) Setting description
* d) Compact disposition
* e) Values for REMMINA_PROTOCOL_SETTING_TYPE_SELECT or REMMINA_PROTOCOL_SETTING_TYPE_COMBO
* f) Unused pointer
*/
static const RemminaProtocolSetting remmina_sftp_basic_settings[] =
{
{ REMMINA_PROTOCOL_SETTING_TYPE_SERVER, "ssh_server", NULL, FALSE, NULL, NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_TEXT, "ssh_username", N_("User name"), FALSE, NULL, NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_PASSWORD, "ssh_password", N_("User password"), FALSE, NULL, NULL },
{ REMMINA_PROTOCOL_SETTING_TYPE_END, NULL, NULL, FALSE, NULL, NULL }
};

/* Protocol plugin definition and features */
static RemminaProtocolPlugin remmina_plugin_sftp =
{
Expand All @@ -295,7 +313,7 @@ static RemminaProtocolPlugin remmina_plugin_sftp =
VERSION, // Version number
"remmina-sftp", // Icon for normal connection
"remmina-sftp", // Icon for SSH connection
NULL, // Array for basic settings
remmina_sftp_basic_settings, // Array for basic settings
NULL, // Array for advanced settings
REMMINA_PROTOCOL_SSH_SETTING_SFTP, // SSH settings type
remmina_plugin_sftp_features, // Array for available features
Expand Down
Loading

0 comments on commit fbf619a

Please sign in to comment.