Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/common-ssh/common-ssh/sftp.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,18 @@ typedef struct guac_common_ssh_sftp_ls_state {
LIBSSH2_SFTP_HANDLE* directory;

/**
* The absolute path of the directory being listed.
* The absolute path of the directory being listed, as exposed to the
* client via the Guacamole protocol stream name.
*/
char directory_name[GUAC_COMMON_SSH_SFTP_MAX_PATH];

/**
* The real, server-side filesystem path of the directory being listed,
* including any configured SFTP root prefix. Used to resolve symlinks
* during listing when the SFTP root is not "/".
*/
char directory_real_path[GUAC_COMMON_SSH_SFTP_MAX_PATH];

/**
* The current state of the JSON directory object being written.
*/
Expand Down
11 changes: 9 additions & 2 deletions src/common-ssh/sftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,12 @@ static int guac_common_ssh_sftp_ls_ack_handler(guac_user* user,
}

/* Stat explicitly if symbolic link (might point to directory) */
if (LIBSSH2_SFTP_S_ISLNK(attributes.permissions))
libssh2_sftp_stat(sftp, absolute_path, &attributes);
if (LIBSSH2_SFTP_S_ISLNK(attributes.permissions)) {
char real_path[GUAC_COMMON_SSH_SFTP_MAX_PATH];
if (guac_ssh_append_filename(real_path,
list_state->directory_real_path, filename))
libssh2_sftp_stat(sftp, real_path, &attributes);
}

/* Determine mimetype */
const char* mimetype;
Expand Down Expand Up @@ -791,6 +795,9 @@ static int guac_common_ssh_sftp_get_handler(guac_user* user,
return 0;
}

guac_strlcpy(list_state->directory_real_path, fullpath,
sizeof(list_state->directory_real_path));

/* Allocate stream for body */
guac_stream* stream = guac_user_alloc_stream(user);
stream->ack_handler = guac_common_ssh_sftp_ls_ack_handler;
Expand Down
Loading