diff options
-rw-r--r-- | plugins/nx/nx_plugin.c | 46 | ||||
-rw-r--r-- | plugins/rdp/rdp_plugin.c | 75 | ||||
-rw-r--r-- | plugins/spice/spice_plugin.c | 30 | ||||
-rw-r--r-- | plugins/vnc/vnc_plugin.c | 40 | ||||
-rw-r--r-- | plugins/www/www_plugin.c | 33 | ||||
-rw-r--r-- | src/include/remmina/plugin.h | 4 | ||||
-rw-r--r-- | src/include/remmina/types.h | 7 | ||||
-rw-r--r-- | src/remmina_message_panel.h | 5 | ||||
-rw-r--r-- | src/remmina_plugin_manager.c | 3 | ||||
-rw-r--r-- | src/remmina_protocol_widget.c | 134 | ||||
-rw-r--r-- | src/remmina_protocol_widget.h | 3 | ||||
-rw-r--r-- | src/remmina_ssh.c | 90 |
12 files changed, 274 insertions, 196 deletions
diff --git a/plugins/nx/nx_plugin.c b/plugins/nx/nx_plugin.c index c16f0bfda..8b98f1cea 100644 --- a/plugins/nx/nx_plugin.c +++ b/plugins/nx/nx_plugin.c @@ -198,13 +198,16 @@ gboolean remmina_plugin_nx_ssh_auth_callback(gchar **passphrase, gpointer userda gint ret; /* SSH passwords must not be saved */ - ret = remmina_plugin_nx_service->protocol_plugin_init_authpwd(gp, REMMINA_AUTHPWD_TYPE_SSH_PRIVKEY, FALSE); - - if (ret != GTK_RESPONSE_OK) + ret = remmina_plugin_nx_service->protocol_plugin_init_auth(gp, 0, + _("SSH credentials"), NULL, + NULL, + NULL, + _("SSH private key passphrase")); + if (ret == GTK_RESPONSE_OK) { + *passphrase = remmina_plugin_nx_service->protocol_plugin_init_get_password(gp); + return TRUE; + } else return FALSE; - *passphrase = remmina_plugin_nx_service->protocol_plugin_init_get_password(gp); - - return TRUE; } static void remmina_plugin_nx_on_proxy_exit(GPid pid, gint status, gpointer data) @@ -355,15 +358,34 @@ static gboolean remmina_plugin_nx_start_session(RemminaProtocolWidget *gp) g_free(s1); g_free(s2); + gchar *s_username, *s_password; + disablepasswordstoring = remmina_plugin_nx_service->file_get_int(remminafile, "disablepasswordstoring", FALSE); - ret = remmina_plugin_nx_service->protocol_plugin_init_authuserpwd(gp, FALSE, !disablepasswordstoring); - if (ret != GTK_RESPONSE_OK) - return FALSE; + ret = remmina_plugin_nx_service->protocol_plugin_init_auth(gp, + (disablepasswordstoring ? 0 : REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD) | REMMINA_MESSAGE_PANEL_FLAG_USERNAME, + _("Enter NX authentication credentials"), + remmina_plugin_nx_service->file_get_string(remminafile, "username"), + remmina_plugin_nx_service->file_get_string(remminafile, "password"), + NULL, + NULL); + if (ret == GTK_RESPONSE_OK) { + gboolean save; + s_username = remmina_plugin_nx_service->protocol_plugin_init_get_username(gp); + s_password = remmina_plugin_nx_service->protocol_plugin_init_get_password(gp); + save = remmina_plugin_nx_service->protocol_plugin_init_get_savepassword(gp); + if (save) { + remmina_plugin_nx_service->file_set_string(remminafile, "username", s_username); + remmina_plugin_nx_service->file_set_string(remminafile, "password", s_password); + } else + remmina_plugin_nx_service->file_unsave_passwords(remminafile); + } else { + return False; + } - s1 = remmina_plugin_nx_service->protocol_plugin_init_get_username(gp); - s2 = remmina_plugin_nx_service->protocol_plugin_init_get_password(gp); - ret = remmina_nx_session_login(nx, s1, s2); + ret = remmina_nx_session_login(nx, s_username, s_password); + g_free(s_username); + g_free(s_password); } g_free(s1); g_free(s2); diff --git a/plugins/rdp/rdp_plugin.c b/plugins/rdp/rdp_plugin.c index 4e1de01ce..c933c62ac 100644 --- a/plugins/rdp/rdp_plugin.c +++ b/plugins/rdp/rdp_plugin.c @@ -572,8 +572,14 @@ static BOOL remmina_rdp_authenticate(freerdp *instance, char **username, char ** gp = rfi->protocol_widget; remminafile = remmina_plugin_service->protocol_plugin_get_file(gp); disablepasswordstoring = remmina_plugin_service->file_get_int(remminafile, "disablepasswordstoring", FALSE); - ret = remmina_plugin_service->protocol_plugin_init_authuserpwd(gp, TRUE, !disablepasswordstoring); + ret = remmina_plugin_service->protocol_plugin_init_auth(gp, + (disablepasswordstoring ? 0 : REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD) | REMMINA_MESSAGE_PANEL_FLAG_USERNAME | REMMINA_MESSAGE_PANEL_FLAG_DOMAIN, + _("Enter RDP authentication credentials"), + remmina_plugin_service->file_get_string(remminafile, "username"), + remmina_plugin_service->file_get_string(remminafile, "password"), + remmina_plugin_service->file_get_string(remminafile, "domain"), + NULL); if (ret == GTK_RESPONSE_OK) { s_username = remmina_plugin_service->protocol_plugin_init_get_username(gp); if (s_username) rfi->settings->Username = strdup(s_username); @@ -593,63 +599,25 @@ static BOOL remmina_rdp_authenticate(freerdp *instance, char **username, char ** remmina_plugin_service->file_set_string(remminafile, "username", s_username); remmina_plugin_service->file_set_string(remminafile, "password", s_password); remmina_plugin_service->file_set_string(remminafile, "domain", s_domain); + } else { + remmina_plugin_service->file_set_string(remminafile, "username", NULL); + remmina_plugin_service->file_set_string(remminafile, "password", NULL); + remmina_plugin_service->file_set_string(remminafile, "domain", NULL); } + if (s_username) g_free(s_username); if (s_password) g_free(s_password); if (s_domain) g_free(s_domain); - return True; + return TRUE; } else { - return False; + return FALSE; } - return True; + return TRUE; } -static BOOL remmina_rdp_proxy_authenticate(RemminaProtocolWidget *gp) -{ - TRACE_CALL(__func__); - rfContext *rfi = GET_PLUGIN_DATA(gp); - gchar *p_username, *p_password; - gint ret; - gboolean save; - gboolean disablepasswordstoring; - RemminaFile *remminafile; - - remminafile = remmina_plugin_service->protocol_plugin_get_file(gp); - - if (!remmina_plugin_service->file_get_string(remminafile, "proxy_hostname")) - return False; - disablepasswordstoring = remmina_plugin_service->file_get_int(remminafile, "disablepasswordstoring", FALSE); - ret = remmina_plugin_service->protocol_plugin_init_authuserpwd(gp, TRUE, !disablepasswordstoring); - if (ret == GTK_RESPONSE_OK) { - p_username = remmina_plugin_service->protocol_plugin_init_get_username(gp); - if (p_username) rfi->settings->ProxyUsername = strdup(p_username); - - p_password = remmina_plugin_service->protocol_plugin_init_get_password(gp); - if (p_password) rfi->settings->ProxyPassword = strdup(p_password); - - save = remmina_plugin_service->protocol_plugin_init_get_savepassword(gp); - if (save) { - // User has requested to save credentials. We put all the new cretentials - // into remminafile->settings. They will be saved later, on successful connection, by - // rcw.c - - remmina_plugin_service->file_set_string(remminafile, "proxy_username", p_username); - remmina_plugin_service->file_set_string(remminafile, "proxy_password", p_password); - } - - if (p_username) g_free(p_username); - if (p_password) g_free(p_password); - - return True; - } else { - return False; - } - - return True; -} static BOOL remmina_rdp_gw_authenticate(freerdp *instance, char **username, char **password, char **domain) { TRACE_CALL(__func__); @@ -668,7 +636,14 @@ static BOOL remmina_rdp_gw_authenticate(freerdp *instance, char **username, char if (!remmina_plugin_service->file_get_string(remminafile, "gateway_server")) return False; disablepasswordstoring = remmina_plugin_service->file_get_int(remminafile, "disablepasswordstoring", FALSE); - ret = remmina_plugin_service->protocol_plugin_init_authuserpwd(gp, TRUE, !disablepasswordstoring); + + ret = remmina_plugin_service->protocol_plugin_init_auth(gp, + (disablepasswordstoring ? 0 : REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD) | REMMINA_MESSAGE_PANEL_FLAG_USERNAME | REMMINA_MESSAGE_PANEL_FLAG_DOMAIN, + _("Enter RDP gateway authentication credentials"), + remmina_plugin_service->file_get_string(remminafile, "gateway_username"), + remmina_plugin_service->file_get_string(remminafile, "gateway_password"), + remmina_plugin_service->file_get_string(remminafile, "gateway_domain"), + NULL); if (ret == GTK_RESPONSE_OK) { s_username = remmina_plugin_service->protocol_plugin_init_get_username(gp); @@ -689,6 +664,10 @@ static BOOL remmina_rdp_gw_authenticate(freerdp *instance, char **username, char remmina_plugin_service->file_set_string(remminafile, "gateway_username", s_username); remmina_plugin_service->file_set_string(remminafile, "gateway_password", s_password); remmina_plugin_service->file_set_string(remminafile, "gateway_domain", s_domain); + } else { + remmina_plugin_service->file_set_string(remminafile, "gateway_username", NULL); + remmina_plugin_service->file_set_string(remminafile, "gateway_password", NULL); + remmina_plugin_service->file_set_string(remminafile, "gateway_domain", NULL); } if (s_username) g_free(s_username); diff --git a/plugins/spice/spice_plugin.c b/plugins/spice/spice_plugin.c index 794a503ce..edb29394a 100644 --- a/plugins/spice/spice_plugin.c +++ b/plugins/spice/spice_plugin.c @@ -226,25 +226,35 @@ static gboolean remmina_plugin_spice_ask_auth(RemminaProtocolWidget *gp) gint ret; gboolean disablepasswordstoring; + gchar *s_password; + gboolean save; RemminaPluginSpiceData *gpdata = GET_PLUGIN_DATA(gp); RemminaFile *remminafile = remmina_plugin_service->protocol_plugin_get_file(gp); disablepasswordstoring = remmina_plugin_service->file_get_int(remminafile, "disablepasswordstoring", FALSE); - ret = remmina_plugin_service->protocol_plugin_init_authpwd(gp, REMMINA_AUTHPWD_TYPE_PROTOCOL, !disablepasswordstoring); + ret = remmina_plugin_service->protocol_plugin_init_auth(gp, + (disablepasswordstoring ? 0 : REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD), + _("Enter SPICE password"), + NULL, + remmina_plugin_service->file_get_string(remminafile, "password"), + NULL, + NULL); if (ret == GTK_RESPONSE_OK) { - gchar *password = remmina_plugin_service->protocol_plugin_init_get_password(gp); - if (remmina_plugin_service->protocol_plugin_init_get_savepassword(gp)) - remmina_plugin_service->file_set_string( remminafile, "password", password ); - g_object_set(gpdata->session, - "password", - password, - NULL); - return TRUE; - }else { + s_password = remmina_plugin_service->protocol_plugin_init_get_password(gp); + save = remmina_plugin_service->protocol_plugin_init_get_savepassword(gp); + if (save) { + remmina_plugin_service->file_set_string(remminafile, "password", s_password); + } else { + remmina_plugin_service->file_set_string(remminafile, "password", NULL); + } + } else { return FALSE; } + + g_object_set(gpdata->session, s_password); + return TRUE; } static void remmina_plugin_spice_main_channel_event_cb(SpiceChannel *channel, SpiceChannelEvent event, RemminaProtocolWidget *gp) diff --git a/plugins/vnc/vnc_plugin.c b/plugins/vnc/vnc_plugin.c index 08bff2109..200a7c97a 100644 --- a/plugins/vnc/vnc_plugin.c +++ b/plugins/vnc/vnc_plugin.c @@ -727,13 +727,25 @@ remmina_plugin_vnc_rfb_password(rfbClient *cl) if (gpdata->auth_first) pwd = g_strdup(remmina_plugin_service->file_get_string(remminafile, "password")); if (!pwd) { + gboolean save; disablepasswordstoring = remmina_plugin_service->file_get_int(remminafile, "disablepasswordstoring", FALSE); - ret = remmina_plugin_service->protocol_plugin_init_authpwd(gp, REMMINA_AUTHPWD_TYPE_PROTOCOL, !disablepasswordstoring); - - if (ret == GTK_RESPONSE_OK) - pwd = remmina_plugin_service->protocol_plugin_init_get_password(gp); - else + ret = remmina_plugin_service->protocol_plugin_init_auth(gp, + (disablepasswordstoring ? 0 : REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD), + _("Enter VNC password"), + NULL, + remmina_plugin_service->file_get_string(remminafile, "password"), + NULL, + NULL); + if (ret != GTK_RESPONSE_OK) { gpdata->connected = FALSE; + return NULL; + } + pwd = remmina_plugin_service->protocol_plugin_init_get_password(gp); + save = remmina_plugin_service->protocol_plugin_init_get_savepassword(gp); + if (save) + remmina_plugin_service->file_set_string(remminafile, "password", pwd); + else + remmina_plugin_service->file_set_string(remminafile, "password", NULL); } return pwd; } @@ -770,12 +782,24 @@ remmina_plugin_vnc_rfb_credential(rfbClient *cl, int credentialType) g_free(s2); disablepasswordstoring = remmina_plugin_service->file_get_int(remminafile, "disablepasswordstoring", FALSE); - ret = remmina_plugin_service->protocol_plugin_init_authuserpwd(gp, FALSE, !disablepasswordstoring); - - + ret = remmina_plugin_service->protocol_plugin_init_auth(gp, + (disablepasswordstoring ? 0 : REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD) | REMMINA_MESSAGE_PANEL_FLAG_USERNAME, + _("Enter VNC authentication credentials"), + remmina_plugin_service->file_get_string(remminafile, "username"), + remmina_plugin_service->file_get_string(remminafile, "password"), + NULL, + NULL); if (ret == GTK_RESPONSE_OK) { + gboolean save = remmina_plugin_service->protocol_plugin_init_get_savepassword(gp); cred->userCredential.username = remmina_plugin_service->protocol_plugin_init_get_username(gp); cred->userCredential.password = remmina_plugin_service->protocol_plugin_init_get_password(gp); + if (save) { + remmina_plugin_service->file_set_string(remminafile, "username", cred->userCredential.username); + remmina_plugin_service->file_set_string(remminafile, "password", cred->userCredential.password); + } else { + remmina_plugin_service->file_set_string(remminafile, "username", NULL); + remmina_plugin_service->file_set_string(remminafile, "password", NULL); + } } else { g_free(cred); cred = NULL; diff --git a/plugins/www/www_plugin.c b/plugins/www/www_plugin.c index 6e047a1b8..dca97ebc8 100644 --- a/plugins/www/www_plugin.c +++ b/plugins/www/www_plugin.c @@ -473,7 +473,6 @@ static gboolean remmina_plugin_www_on_auth(WebKitWebView *webview, WebKitAuthent gboolean disablepasswordstoring; RemminaFile *remminafile; - gpdata = (RemminaPluginWWWData *)g_object_get_data(G_OBJECT(gp), "plugin-data"); g_info("Authenticate"); @@ -481,13 +480,25 @@ static gboolean remmina_plugin_www_on_auth(WebKitWebView *webview, WebKitAuthent remminafile = remmina_plugin_service->protocol_plugin_get_file(gp); disablepasswordstoring = remmina_plugin_service->file_get_int(remminafile, "disablepasswordstoring", FALSE); - ret = remmina_plugin_service->protocol_plugin_init_authuserpwd(gp, FALSE, !disablepasswordstoring); - + ret = remmina_plugin_service->protocol_plugin_init_auth(gp, + (disablepasswordstoring ? 0 : REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD) | REMMINA_MESSAGE_PANEL_FLAG_USERNAME, + _("Enter WWW authentication credentials"), + remmina_plugin_service->file_get_string(remminafile, "username"), + remmina_plugin_service->file_get_string(remminafile, "password"), + NULL, + NULL); if (ret == GTK_RESPONSE_OK) { s_username = remmina_plugin_service->protocol_plugin_init_get_username(gp); s_password = remmina_plugin_service->protocol_plugin_init_get_password(gp); - if (remmina_plugin_service->protocol_plugin_init_get_savepassword(gp)) + + save = remmina_plugin_service->protocol_plugin_init_get_savepassword(gp); + if (save) { + remmina_plugin_service->file_set_string(remminafile, "username", s_username); remmina_plugin_service->file_set_string(remminafile, "password", s_password); + } else { + remmina_plugin_service->file_set_string(remminafile, "username", NULL); + remmina_plugin_service->file_set_string(remminafile, "password", NULL); + } if (request) { gpdata->credentials = webkit_credential_new( g_strdup(s_username), @@ -496,22 +507,8 @@ static gboolean remmina_plugin_www_on_auth(WebKitWebView *webview, WebKitAuthent webkit_authentication_request_authenticate(request, gpdata->credentials); webkit_credential_free(gpdata->credentials); } - - save = remmina_plugin_service->protocol_plugin_init_get_savepassword(gp); - if (save) { - // The user has requested to save credentials. We put all the new credentials - // into remminafile->settings. They will be saved later, upon connection, by - // rcw.c - - remmina_plugin_service->file_set_string(remminafile, "username", s_username); - remmina_plugin_service->file_set_string(remminafile, "password", s_password); - } - if (s_username) g_free(s_username); if (s_password) g_free(s_password); - - /* Free credentials */ - gpdata->authenticated = TRUE; } else { gpdata->authenticated = FALSE; diff --git a/src/include/remmina/plugin.h b/src/include/remmina/plugin.h index d08abd770..f5a14cbe1 100644 --- a/src/include/remmina/plugin.h +++ b/src/include/remmina/plugin.h @@ -170,8 +170,8 @@ typedef struct _RemminaPluginService { void (* protocol_plugin_update_align)(RemminaProtocolWidget *gp); void (* protocol_plugin_unlock_dynres)(RemminaProtocolWidget *gp); void (* protocol_plugin_desktop_resize)(RemminaProtocolWidget *gp); - gint (* protocol_plugin_init_authpwd)(RemminaProtocolWidget *gp, RemminaAuthpwdType authpwd_type, gboolean allow_password_saving); - gint (* protocol_plugin_init_authuserpwd)(RemminaProtocolWidget *gp, gboolean want_domain, gboolean allow_password_saving); + gint (* protocol_plugin_init_auth)(RemminaProtocolWidget *gp, RemminaMessagePanelFlags pflags, const gchar *title, const gchar *default_username, const gchar *default_password, + const gchar *default_domain, const gchar *password_prompt); gint (* protocol_plugin_init_certificate)(RemminaProtocolWidget *gp, const gchar* subject, const gchar* issuer, const gchar* fingerprint); gint (* protocol_plugin_changed_certificate)(RemminaProtocolWidget *gp, const gchar* subject, const gchar* issuer, const gchar* new_fingerprint, const gchar* old_fingerprint); gchar* (*protocol_plugin_init_get_username)(RemminaProtocolWidget * gp); diff --git a/src/include/remmina/types.h b/src/include/remmina/types.h index 71bc10ac3..f7a9e03de 100644 --- a/src/include/remmina/types.h +++ b/src/include/remmina/types.h @@ -128,6 +128,13 @@ typedef enum { RES_USE_INITIAL_WINDOW_SIZE = 2 } RemminaProtocolWidgetResolutionMode; +/* pflags field for remmina_protocol_widget_panel_auth() */ +typedef enum { + REMMINA_MESSAGE_PANEL_FLAG_USERNAME = 1, /* require username in auth panel */ + REMMINA_MESSAGE_PANEL_FLAG_DOMAIN = 2, /* require domain in auth panel */ + REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD = 4 /* require savepassword switch in auth panel */ +} RemminaMessagePanelFlags; + G_END_DECLS diff --git a/src/remmina_message_panel.h b/src/remmina_message_panel.h index 9ec0d5581..b2cdc77c1 100644 --- a/src/remmina_message_panel.h +++ b/src/remmina_message_panel.h @@ -46,11 +46,6 @@ struct _RemminaMessagePanelClass { void (* response) (RemminaMessagePanel *mp, gint response_id); }; -enum { - REMMINA_MESSAGE_PANEL_FLAG_USERNAME=1, - REMMINA_MESSAGE_PANEL_FLAG_DOMAIN=2, - REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD=4 -}; /* Widgets ID for dialog fields */ enum { diff --git a/src/remmina_plugin_manager.c b/src/remmina_plugin_manager.c index 9881ac0df..f20921c01 100644 --- a/src/remmina_plugin_manager.c +++ b/src/remmina_plugin_manager.c @@ -188,8 +188,7 @@ RemminaPluginService remmina_plugin_manager_service = remmina_protocol_widget_update_align, remmina_protocol_widget_unlock_dynres, remmina_protocol_widget_desktop_resize, - remmina_protocol_widget_panel_authpwd, - remmina_protocol_widget_panel_authuserpwd, + remmina_protocol_widget_panel_auth, remmina_protocol_widget_panel_new_certificate, remmina_protocol_widget_panel_changed_certificate, remmina_protocol_widget_get_username, diff --git a/src/remmina_protocol_widget.c b/src/remmina_protocol_widget.c index e8fbaedc5..7431472ee 100644 --- a/src/remmina_protocol_widget.c +++ b/src/remmina_protocol_widget.c @@ -103,9 +103,7 @@ struct _RemminaProtocolWidgetPriv { }; enum panel_type { - RPWDT_AUTHUSERPWD, - RPWDT_AUTHUSERPWD_SSHTUNNEL, - RPWDT_AUTHPWD, + RPWDT_AUTH, RPWDT_QUESTIONYESNO, RPWDT_AUTHX509 }; @@ -303,9 +301,12 @@ void remmina_protocol_widget_open_connection(RemminaProtocolWidget* gp) remmina_protocol_widget_open_connection_real(gp); } -static gboolean conn_closed(RemminaProtocolWidget* gp) +static gboolean conn_closed(gpointer data) { /* Close ssh tunnel */ + TRACE_CALL(__func__); + RemminaProtocolWidget *gp = (RemminaProtocolWidget *)data; + #ifdef HAVE_LIBSSH if (gp->priv->ssh_tunnel) { remmina_ssh_tunnel_free(gp->priv->ssh_tunnel); @@ -328,9 +329,11 @@ void remmina_protocol_widget_signal_connection_closed(RemminaProtocolWidget* gp) g_idle_add(conn_closed, (gpointer)gp); } -static gboolean conn_opened(RemminaProtocolWidget* gp) +static gboolean conn_opened(gpointer data) { TRACE_CALL(__func__); + RemminaProtocolWidget *gp = (RemminaProtocolWidget *)data; + #ifdef HAVE_LIBSSH if (gp->priv->ssh_tunnel) { remmina_ssh_tunnel_cancel_accept(gp->priv->ssh_tunnel); @@ -356,8 +359,11 @@ void remmina_protocol_widget_signal_connection_opened(RemminaProtocolWidget* gp) g_idle_add(conn_opened, (gpointer)gp); } -static gboolean update_align(RemminaProtocolWidget* gp) +static gboolean update_align(gpointer data) { + TRACE_CALL(__func__); + RemminaProtocolWidget *gp = (RemminaProtocolWidget *)data; + g_signal_emit_by_name(G_OBJECT(gp), "update-align"); return G_SOURCE_REMOVE; } @@ -369,8 +375,10 @@ void remmina_protocol_widget_update_align(RemminaProtocolWidget* gp) g_idle_add(update_align, (gpointer)gp); } -static gboolean unlock_dynres(RemminaProtocolWidget* gp) +static gboolean unlock_dynres(gpointer data) { + TRACE_CALL(__func__); + RemminaProtocolWidget *gp = (RemminaProtocolWidget *)data; g_signal_emit_by_name(G_OBJECT(gp), "unlock-dynres"); return G_SOURCE_REMOVE; } @@ -382,8 +390,10 @@ void remmina_protocol_widget_unlock_dynres(RemminaProtocolWidget* gp) g_idle_add(unlock_dynres, (gpointer)gp); } -static gboolean desktop_resize(RemminaProtocolWidget* gp) +static gboolean desktop_resize(gpointer data) { + TRACE_CALL(__func__); + RemminaProtocolWidget *gp = (RemminaProtocolWidget *)data; g_signal_emit_by_name(G_OBJECT(gp), "desktop-resize"); return G_SOURCE_REMOVE; } @@ -1121,9 +1131,13 @@ RemminaFile* remmina_protocol_widget_get_file(RemminaProtocolWidget* gp) struct remmina_protocol_widget_dialog_mt_data_t { /* Input data */ RemminaProtocolWidget *gp; - char *str1; + gchar *title; + gchar *default_username; + gchar *default_password; + gchar *default_domain; + gchar *strpasswordlabel; enum panel_type dtype; - unsigned pflags; + RemminaMessagePanelFlags pflags; gboolean called_from_subthread; /* Running status */ pthread_mutex_t pt_mutex; @@ -1132,12 +1146,12 @@ struct remmina_protocol_widget_dialog_mt_data_t { int rcbutton; }; -static void authuserpwd_mt_cb(void *user_data, int button) +static void authpanel_mt_cb(void *user_data, int button) { struct remmina_protocol_widget_dialog_mt_data_t *d = (struct remmina_protocol_widget_dialog_mt_data_t *)user_data; d->rcbutton = button; if (button == GTK_RESPONSE_OK) { - if (d->dtype == RPWDT_AUTHUSERPWD || d->dtype == RPWDT_AUTHPWD || d->dtype == RPWDT_AUTHUSERPWD_SSHTUNNEL) { + if (d->dtype == RPWDT_AUTH) { d->gp->priv->password = remmina_message_panel_field_get_string(d->gp->priv->auth_message_panel, REMMINA_MESSAGE_PANEL_PASSWORD); d->gp->priv->username = remmina_message_panel_field_get_string(d->gp->priv->auth_message_panel, REMMINA_MESSAGE_PANEL_USERNAME); d->gp->priv->domain = remmina_message_panel_field_get_string(d->gp->priv->auth_message_panel, REMMINA_MESSAGE_PANEL_DOMAIN); @@ -1171,39 +1185,23 @@ static gboolean remmina_protocol_widget_dialog_mt_setup(gpointer user_data) RemminaFile* remminafile = d->gp->priv->remmina_file; RemminaMessagePanel *mp; - const gchar *key; const gchar *s; mp = remmina_message_panel_new(); - if (d->dtype == RPWDT_AUTHUSERPWD || d->dtype == RPWDT_AUTHUSERPWD_SSHTUNNEL) { - remmina_message_panel_setup_auth(mp, authuserpwd_mt_cb, d, - d->dtype == RPWDT_AUTHUSERPWD_SSHTUNNEL ? _("Enter SSH tunnel authentication credentials") : _("Enter authentication credentials"), - d->str1, d->pflags); - key = (d->dtype == RPWDT_AUTHUSERPWD_SSHTUNNEL ? "ssh_username" : "username"); - if ((s = remmina_file_get_string(remminafile, key)) != NULL) - remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_USERNAME, s); - if (d->dtype == RPWDT_AUTHUSERPWD && (d->pflags & REMMINA_MESSAGE_PANEL_FLAG_DOMAIN) && (s = remmina_file_get_string(remminafile, "domain")) != NULL) - remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_DOMAIN, s); - key = (d->dtype == RPWDT_AUTHUSERPWD_SSHTUNNEL ? "ssh_password" : "password"); - if ((s = remmina_file_get_string(remminafile, key)) != NULL) - remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_PASSWORD, s); + if (d->dtype == RPWDT_AUTH) { + remmina_message_panel_setup_auth(mp, authpanel_mt_cb, d, d->title, d->strpasswordlabel, d->pflags); + remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_USERNAME, d->default_username); + if (d->pflags & REMMINA_MESSAGE_PANEL_FLAG_DOMAIN) + remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_DOMAIN, d->default_domain); + remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_PASSWORD, d->default_password); if (d->pflags & REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD) { - remmina_message_panel_field_set_switch(mp, REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD, FALSE); - } - } else if (d->dtype == RPWDT_AUTHPWD) { - remmina_message_panel_setup_auth(mp, authuserpwd_mt_cb, d, _("Enter authentication credentials"), d->str1, d->pflags); - if ((s = remmina_file_get_string(remminafile, "username")) != NULL) - remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_USERNAME, s); - if ((s = remmina_file_get_string(remminafile, "password")) != NULL) - remmina_message_panel_field_set_string(mp, REMMINA_MESSAGE_PANEL_PASSWORD, s); - if (d->pflags & REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD) { - remmina_message_panel_field_set_switch(mp, REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD, FALSE); + remmina_message_panel_field_set_switch(mp, REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD, (d->pflags & REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD) ? TRUE: FALSE); } } else if (d->dtype == RPWDT_QUESTIONYESNO) { - remmina_message_panel_setup_question(mp, d->str1, authuserpwd_mt_cb, d); + remmina_message_panel_setup_question(mp, d->title, authpanel_mt_cb, d); } else if (d->dtype == RPWDT_AUTHX509) { - remmina_message_panel_setup_auth_x509(mp, authuserpwd_mt_cb, d); + remmina_message_panel_setup_auth_x509(mp, authpanel_mt_cb, d); if ((s = remmina_file_get_string(remminafile, "cacert")) != NULL) remmina_message_panel_field_set_filename(mp, REMMINA_MESSAGE_PANEL_CACERTFILE, s); if ((s = remmina_file_get_string(remminafile, "cacrl")) != NULL) @@ -1256,8 +1254,11 @@ static void run_destroy_handler (RemminaMessagePanel *mp, gpointer data) shutdown_loop(mpri); } -static int remmina_protocol_widget_dialog(enum panel_type dtype, RemminaProtocolWidget* gp, unsigned pflags, const char *str1) +static int remmina_protocol_widget_dialog(enum panel_type dtype, RemminaProtocolWidget* gp, RemminaMessagePanelFlags pflags, + const gchar *title, const gchar *default_username, const gchar *default_password, const gchar *default_domain, + const gchar *strpasswordlabel) { + TRACE_CALL(__func__); struct remmina_protocol_widget_dialog_mt_data_t *d = (struct remmina_protocol_widget_dialog_mt_data_t*)g_malloc( sizeof(struct remmina_protocol_widget_dialog_mt_data_t) ); int rcbutton; @@ -1265,7 +1266,11 @@ static int remmina_protocol_widget_dialog(enum panel_type dtype, RemminaProtocol d->gp = gp; d->pflags = pflags; d->dtype = dtype; - d->str1 = g_strdup(str1); + d->title = g_strdup(title); + d->strpasswordlabel = g_strdup(strpasswordlabel); + d->default_username = g_strdup(default_username); + d->default_password = g_strdup(default_password); + d->default_domain = g_strdup(default_domain); d->called_from_subthread = FALSE; if (remmina_masterthread_exec_is_main_thread()) { @@ -1318,7 +1323,11 @@ static int remmina_protocol_widget_dialog(enum panel_type dtype, RemminaProtocol rcbutton = d->rcbutton; } - g_free(d->str1); + g_free(d->title); + g_free(d->strpasswordlabel); + g_free(d->default_username); + g_free(d->default_password); + g_free(d->default_domain); g_free(d); return rcbutton; @@ -1326,27 +1335,15 @@ static int remmina_protocol_widget_dialog(enum panel_type dtype, RemminaProtocol gint remmina_protocol_widget_panel_question_yesno(RemminaProtocolWidget* gp, const char *msg) { - return remmina_protocol_widget_dialog(RPWDT_QUESTIONYESNO, gp, 0, msg); + return remmina_protocol_widget_dialog(RPWDT_QUESTIONYESNO, gp, 0, msg, NULL, NULL, NULL, NULL); } -gint remmina_protocol_widget_panel_authuserpwd(RemminaProtocolWidget* gp, gboolean want_domain, gboolean allow_password_saving) +gint remmina_protocol_widget_panel_auth(RemminaProtocolWidget* gp, RemminaMessagePanelFlags pflags, + const gchar *title, const gchar *default_username, const gchar *default_password, const gchar *default_domain, const gchar *password_prompt) { TRACE_CALL(__func__); - unsigned pflags; - RemminaFile* remminafile = gp->priv->remmina_file; - - pflags = REMMINA_MESSAGE_PANEL_FLAG_USERNAME; - g_debug ("pflags is %u", pflags); - if (remmina_file_get_filename(remminafile) != NULL && - !remminafile->prevent_saving && allow_password_saving) - pflags |= REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD; - g_debug ("pflags is %u", pflags); - if (want_domain) - pflags |= REMMINA_MESSAGE_PANEL_FLAG_DOMAIN; - - g_debug ("pflags is %u", pflags); - - return remmina_protocol_widget_dialog(RPWDT_AUTHUSERPWD, gp, pflags, _("Password")); + return remmina_protocol_widget_dialog(RPWDT_AUTH, gp, pflags, title, default_username, + default_password, default_domain, password_prompt == NULL ? _("Password") : password_prompt); } gint remmina_protocol_widget_panel_authuserpwd_ssh_tunnel(RemminaProtocolWidget* gp, gboolean want_domain, gboolean allow_password_saving) @@ -1354,15 +1351,21 @@ gint remmina_protocol_widget_panel_authuserpwd_ssh_tunnel(RemminaProtocolWidget* TRACE_CALL(__func__); unsigned pflags; RemminaFile* remminafile = gp->priv->remmina_file; + const gchar *username, *password; pflags = REMMINA_MESSAGE_PANEL_FLAG_USERNAME; if (remmina_file_get_filename(remminafile) != NULL && !remminafile->prevent_saving && allow_password_saving) pflags |= REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD; - return remmina_protocol_widget_dialog(RPWDT_AUTHUSERPWD_SSHTUNNEL, gp, pflags, _("Password")); + username = remmina_file_get_string(remminafile, "ssh_username"); + password = remmina_file_get_string(remminafile, "ssh_password"); + + return remmina_protocol_widget_dialog(RPWDT_AUTH, gp, pflags, _("Enter SSH tunnel authentication credentials"), username, + password, NULL, _("Password")); } +/* gint remmina_protocol_widget_panel_authpwd(RemminaProtocolWidget* gp, RemminaAuthpwdType authpwd_type, gboolean allow_password_saving) { TRACE_CALL(__func__); @@ -1391,17 +1394,18 @@ gint remmina_protocol_widget_panel_authpwd(RemminaProtocolWidget* gp, RemminaAut break; } - rc = remmina_protocol_widget_dialog(RPWDT_AUTHPWD, gp, pflags, password_prompt); + rc = remmina_protocol_widget_dialog(RPWDT_AUTH, gp, pflags, password_prompt); g_free(password_prompt); return rc; } +*/ gint remmina_protocol_widget_panel_authx509(RemminaProtocolWidget* gp) { TRACE_CALL(__func__); - return remmina_protocol_widget_dialog(RPWDT_AUTHX509, gp, 0, NULL); + return remmina_protocol_widget_dialog(RPWDT_AUTHX509, gp, 0, NULL, NULL, NULL, NULL, NULL); } @@ -1419,7 +1423,7 @@ gint remmina_protocol_widget_panel_new_certificate(RemminaProtocolWidget* gp, co _("Issuer:"), issuer, _("Fingerprint:"), fingerprint, _("Accept Certificate?")); - rc = remmina_protocol_widget_dialog(RPWDT_QUESTIONYESNO, gp, 0, s); + rc = remmina_protocol_widget_dialog(RPWDT_QUESTIONYESNO, gp, 0, s, NULL, NULL, NULL, NULL); g_free(s); /* For compatibility with plugin API: the plugin expects GTK_RESPONSE_OK when user confirms new cert */ @@ -1439,10 +1443,10 @@ gint remmina_protocol_widget_panel_changed_certificate(RemminaProtocolWidget *gp _("The certificate changed! Details:"), _("Subject:"), subject, _("Issuer:"), issuer, - _("Old fingerprint:"), old_fingerprint, - _("New fingerprint:"), new_fingerprint, - _("Accept changed certificate?")); - rc = remmina_protocol_widget_dialog(RPWDT_QUESTIONYESNO, gp, 0, s); + _("Old Fingerprint:"), old_fingerprint, + _("New Fingerprint:"), new_fingerprint, + _("Accept Changed Certificate?")); + rc = remmina_protocol_widget_dialog(RPWDT_QUESTIONYESNO, gp, 0, s, NULL, NULL, NULL, NULL); g_free(s); /* For compatibility with plugin API: The plugin expects GTK_RESPONSE_OK when user confirms new cert */ diff --git a/src/remmina_protocol_widget.h b/src/remmina_protocol_widget.h index 566f6d94b..2108464f6 100644 --- a/src/remmina_protocol_widget.h +++ b/src/remmina_protocol_widget.h @@ -130,8 +130,7 @@ gint remmina_protocol_widget_panel_authuserpwd_ssh_tunnel(RemminaProtocolWidget* /* Dialog panel API used by the plugins */ -gint remmina_protocol_widget_panel_authpwd(RemminaProtocolWidget *gp, RemminaAuthpwdType authpwd_type, gboolean allow_password_saving); -gint remmina_protocol_widget_panel_authuserpwd(RemminaProtocolWidget *gp, gboolean want_domain, gboolean allow_password_saving); +gint remmina_protocol_widget_panel_auth(RemminaProtocolWidget* gp, RemminaMessagePanelFlags pflags, const gchar *title, const gchar *default_username, const gchar *default_password, const gchar *default_domain, const gchar *password_prompt); gint remmina_protocol_widget_panel_new_certificate(RemminaProtocolWidget* gp, const gchar* subject, const gchar* issuer, const gchar* fingerprint); gint remmina_protocol_widget_panel_changed_certificate(RemminaProtocolWidget *gp, const gchar* subject, const gchar* issuer, const gchar* new_fingerprint, const gchar* old_fingerprint); gint remmina_protocol_widget_panel_question_yesno(RemminaProtocolWidget* gp, const char *msg); diff --git a/src/remmina_ssh.c b/src/remmina_ssh.c index 2a8a8c874..b2e56fe98 100644 --- a/src/remmina_ssh.c +++ b/src/remmina_ssh.c @@ -265,24 +265,26 @@ remmina_ssh_auth_auto_pubkey(RemminaSSH *ssh, RemminaProtocolWidget *gp, Remmina gboolean disablepasswordstoring; gboolean save_password; gchar *pwd; - gchar *pwdtype = "ssh_passphrase"; gint ret; if (!ssh->passphrase) { disablepasswordstoring = remmina_file_get_int(remminafile, "disablepasswordstoring", FALSE); - ret = remmina_protocol_widget_panel_authpwd(gp, REMMINA_AUTHPWD_TYPE_SSH_PRIVKEY, !disablepasswordstoring); - save_password = remmina_protocol_widget_get_savepassword(gp); + ret = remmina_protocol_widget_panel_auth(gp, (disablepasswordstoring ? 0 : REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD), + _("SSH credentials"), NULL, + remmina_file_get_string(remminafile, "ssh_privatekey"), + NULL, + _("SSH private key passphrase")); if (ret == GTK_RESPONSE_OK) { - if (save_password) { - pwd = remmina_protocol_widget_get_password(gp); - remmina_file_set_string(remminafile, pwdtype, pwd); - g_free(pwd); - } - } else { + pwd = remmina_protocol_widget_get_password(gp); + save_password = remmina_protocol_widget_get_savepassword(gp); + if (save_password) + remmina_file_set_string(remminafile, "ssh_passphrase", pwd); + else + remmina_file_set_string(remminafile, "ssh_passphrase", NULL); + } else return -1; - } - ssh->passphrase = remmina_protocol_widget_get_password(gp); + ssh->passphrase = pwd; } ret = ssh_userauth_publickey_auto(ssh->session, NULL, ssh->passphrase); @@ -498,23 +500,63 @@ remmina_ssh_auth_gui(RemminaSSH *ssh, RemminaProtocolWidget *gp, RemminaFile *re disablepasswordstoring = remmina_file_get_int(remminafile, "disablepasswordstoring", FALSE); - if (g_strcmp0(pwdtype, "ssh_passphrase") == 0) - ret = remmina_protocol_widget_panel_authpwd(gp, REMMINA_AUTHPWD_TYPE_SSH_PRIVKEY, !disablepasswordstoring); - else if (g_strcmp0(pwdtype, "ssh_password") == 0) - ret = remmina_protocol_widget_panel_authuserpwd_ssh_tunnel(gp, FALSE, !disablepasswordstoring); - else - ret = remmina_protocol_widget_panel_authuserpwd(gp, FALSE, !disablepasswordstoring); - save_password = remmina_protocol_widget_get_savepassword(gp); - - if (ret == GTK_RESPONSE_OK) { - if (save_password) { + if (g_strcmp0(pwdtype, "ssh_passphrase") == 0) { + ret = remmina_protocol_widget_panel_auth(gp, (disablepasswordstoring ? 0 : REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD), + _("SSH credentials"), NULL, + remmina_file_get_string(remminafile, "ssh_privatekey"), + NULL, + _("SSH private key passphrase")); + if (ret == GTK_RESPONSE_OK) { pwd = remmina_protocol_widget_get_password(gp); - remmina_file_set_string(remminafile, pwdtype, pwd); + save_password = remmina_protocol_widget_get_savepassword(gp); + if (save_password) + remmina_file_set_string(remminafile, "ssh_passphrase", pwd); + else + remmina_file_set_string(remminafile, "ssh_passphrase", NULL); g_free(pwd); - } + } else return -1; + } else if (g_strcmp0(pwdtype, "ssh_password") == 0) { + ret = remmina_protocol_widget_panel_auth(gp, (disablepasswordstoring ? 0 : REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD) | REMMINA_MESSAGE_PANEL_FLAG_USERNAME, + _("SSH tunnel credentials"), + remmina_file_get_string(remminafile, "ssh_username"), + remmina_file_get_string(remminafile, "ssh_password"), + NULL, + NULL); + if (ret == GTK_RESPONSE_OK) { + pwd = remmina_protocol_widget_get_username(gp); + remmina_file_set_string(remminafile, "username", pwd); + g_free(pwd); + pwd = remmina_protocol_widget_get_password(gp); + save_password = remmina_protocol_widget_get_savepassword(gp); + if (save_password) + remmina_file_set_string(remminafile, "ssh_password", pwd); + else + remmina_file_set_string(remminafile, "ssh_password", NULL); + g_free(pwd); + } else + return -1; } else { - return -1; + ret = remmina_protocol_widget_panel_auth(gp, (disablepasswordstoring ? 0 : REMMINA_MESSAGE_PANEL_FLAG_SAVEPASSWORD) | REMMINA_MESSAGE_PANEL_FLAG_USERNAME, + _("SSH credentials"), + remmina_file_get_string(remminafile, "username"), + remmina_file_get_string(remminafile, "password"), + NULL, + NULL); + if (ret == GTK_RESPONSE_OK) { + pwd = remmina_protocol_widget_get_username(gp); + remmina_file_set_string(remminafile, "username", pwd); + g_free(pwd); + pwd = remmina_protocol_widget_get_password(gp); + save_password = remmina_protocol_widget_get_savepassword(gp); + if (save_password) + remmina_file_set_string(remminafile, "password", pwd); + else + remmina_file_set_string(remminafile, "password", NULL); + g_free(pwd); + } else + return -1; } + pwd = remmina_protocol_widget_get_password(gp); ret = remmina_ssh_auth(ssh, pwd, gp, remminafile); g_free(pwd); |