diff options
author | Antenore Gatta (tmow) <antenore@simbiosi.org> | 2022-03-02 02:16:52 +0300 |
---|---|---|
committer | Antenore Gatta (tmow) <antenore@simbiosi.org> | 2022-03-02 02:16:52 +0300 |
commit | ee00da15bb97f1063a8bdbed58c625c171054254 (patch) | |
tree | 3c238415042f10c107ba2a0d807e8a0cc9cc41f1 /src/remmina_sftp_client.c | |
parent | d8a0021adec170cd7fb504527487ec65c301839f (diff) |
Honour soft links target.
Closes #2691
Signed-off-by: Antenore Gatta (tmow) <antenore@simbiosi.org>
Diffstat (limited to 'src/remmina_sftp_client.c')
-rw-r--r-- | src/remmina_sftp_client.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/remmina_sftp_client.c b/src/remmina_sftp_client.c index a16e72c0a..4aac1b025 100644 --- a/src/remmina_sftp_client.c +++ b/src/remmina_sftp_client.c @@ -48,6 +48,7 @@ #include <fcntl.h> #endif #include "remmina_public.h" +#include "remmina_log.h" #include "remmina_pref.h" #include "remmina_ssh.h" #include "remmina_sftp_client.h" @@ -73,10 +74,12 @@ remmina_sftp_client_class_init(RemminaSFTPClientClass *klass) if (a->type == 0) \ { \ type = ((a->permissions & 040000) ? REMMINA_FTP_FILE_TYPE_DIR : REMMINA_FTP_FILE_TYPE_FILE); \ + type = ((a->permissions & 0120000) ? REMMINA_FTP_FILE_TYPE_LINK : REMMINA_FTP_FILE_TYPE_FILE); \ } \ else \ { \ type = (a->type == SSH_FILEXFER_TYPE_DIRECTORY ? REMMINA_FTP_FILE_TYPE_DIR : REMMINA_FTP_FILE_TYPE_FILE); \ + if (a->type == SSH_FILEXFER_TYPE_SYMLINK ) type = REMMINA_FTP_FILE_TYPE_LINK; \ } /* ------------------------ The Task Thread routines ----------------------------- */ @@ -274,6 +277,16 @@ remmina_sftp_client_thread_recursive_dir(RemminaSFTPClient *client, RemminaSFTP else dir_path = g_strdup(rootdir_path); tmp = remmina_ssh_unconvert(REMMINA_SSH(sftp), dir_path); + + REMMINA_DEBUG ("%s HELLO", __func__); +#if 0 + gchar *tlink = sftp_readlink (sftp->sftp_sess, tmp); + if (tlink) { + REMMINA_DEBUG ("%s is a link to %s", tmp, tlink); + tmp = g_strdup (tlink); + } + g_free(tlink); +#endif sftpdir = sftp_opendir(sftp->sftp_sess, tmp); g_free(tmp); @@ -689,11 +702,10 @@ remmina_sftp_client_sftp_session_opendir(RemminaSFTPClient *client, const gchar { TRACE_CALL(__func__); sftp_dir sftpdir; - GtkWidget *dialog; sftpdir = sftp_opendir(client->sftp->sftp_sess, (gchar *)dir); if (!sftpdir) { - dialog = gtk_message_dialog_new(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(client))), + GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(client))), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not open the folder ā%sā. %s"), dir, ssh_get_error(REMMINA_SSH(client->sftp)->session)); @@ -708,10 +720,9 @@ static gboolean remmina_sftp_client_sftp_session_closedir(RemminaSFTPClient *client, sftp_dir sftpdir) { TRACE_CALL(__func__); - GtkWidget *dialog; if (!sftp_dir_eof(sftpdir)) { - dialog = gtk_message_dialog_new(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(client))), + GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(client))), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not read from the folder. %s"), ssh_get_error(REMMINA_SSH(client->sftp)->session)); gtk_dialog_run(GTK_DIALOG(dialog)); @@ -750,6 +761,19 @@ remmina_sftp_client_on_opendir(RemminaSFTPClient *client, gchar *dir, gpointer d } } + gchar *tlink = sftp_readlink (client->sftp->sftp_sess, newdir); + if (tlink) { + REMMINA_DEBUG ("%s is a link to %s", newdir, tlink); + newdir = g_strdup (tlink); + if (sftp_opendir (client->sftp->sftp_sess, newdir)) { + REMMINA_DEBUG ("%s is a link to a folder", tlink); + } else { + REMMINA_DEBUG ("%s is a link to a file", tlink); + return; + } + } + g_free(tlink); + tmp = remmina_ssh_unconvert(REMMINA_SSH(client->sftp), newdir); newdir_conv = sftp_canonicalize_path(client->sftp->sftp_sess, tmp); g_free(tmp); |