From 0fb3b42c971c0a7b393cc145898730612a18d29d Mon Sep 17 00:00:00 2001 From: hezw5 Date: Fri, 11 Feb 2022 15:40:19 +0800 Subject: [PATCH 1/5] =?UTF-8?q?1)=20src/common-ssh/sftp.c=20L656=20?= =?UTF-8?q?=E5=9C=A8filesystem=E5=91=BD=E4=BB=A4=E6=97=B6=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0json=E8=BF=94=E5=9B=9E=E5=80=BC=EF=BC=8C=E5=8C=85?= =?UTF-8?q?=E5=90=AB=E6=96=87=E4=BB=B6=E5=A4=A7=E5=B0=8F&=E6=9D=83?= =?UTF-8?q?=E9=99=90=E3=80=82=202)=20src/protocols/rdp/ls.c=20L88=20?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0json=E8=BF=94=E5=9B=9E=E5=80=BC=EF=BC=8C?= =?UTF-8?q?=E5=8C=85=E5=90=AB=E6=96=87=E4=BB=B6=E5=A4=A7=E5=B0=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common-ssh/sftp.c | 24 ++++++++++++++++++++---- src/protocols/rdp/ls.c | 22 ++++++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/common-ssh/sftp.c b/src/common-ssh/sftp.c index 0100cc161c..e91e72d301 100644 --- a/src/common-ssh/sftp.c +++ b/src/common-ssh/sftp.c @@ -653,10 +653,26 @@ static int guac_common_ssh_sftp_ls_ack_handler(guac_user* user, /* Determine mimetype */ const char* mimetype; - if (LIBSSH2_SFTP_S_ISDIR(attributes.permissions)) - mimetype = GUAC_USER_STREAM_INDEX_MIMETYPE; - else - mimetype = "application/octet-stream"; +// if (LIBSSH2_SFTP_S_ISDIR(attributes.permissions)) +// mimetype = GUAC_USER_STREAM_INDEX_MIMETYPE; +// else +// mimetype = "application/octet-stream"; + + //adding file size and permission + char tmpstr[150]; + if (LIBSSH2_SFTP_S_ISDIR(attributes.permissions)) { + //mimetype = GUAC_USER_STREAM_INDEX_MIMETYPE; + sprintf(tmpstr, "{\"mime\":\"%s\",\"size\":%llu,\"perm\":%lu}", + GUAC_USER_STREAM_INDEX_MIMETYPE, attributes.filesize, + attributes.permissions); + } + else { + //mimetype = "application/octet-stream"; + sprintf(tmpstr, "{\"mime\":\"%s\",\"size\":%llu,\"perm\":%lu}", + "application/octet-stream", attributes.filesize, + attributes.permissions); + } + mimetype = tmpstr; /* Write entry, waiting for next ack if a blob is written */ if (guac_common_json_write_property(user, stream, diff --git a/src/protocols/rdp/ls.c b/src/protocols/rdp/ls.c index 300bf93c3d..b117af3feb 100644 --- a/src/protocols/rdp/ls.c +++ b/src/protocols/rdp/ls.c @@ -85,10 +85,24 @@ int guac_rdp_ls_ack_handler(guac_user* user, guac_stream* stream, /* Determine mimetype */ const char* mimetype; - if (file->attributes & FILE_ATTRIBUTE_DIRECTORY) - mimetype = GUAC_USER_STREAM_INDEX_MIMETYPE; - else - mimetype = "application/octet-stream"; +// if (file->attributes & FILE_ATTRIBUTE_DIRECTORY) +// mimetype = GUAC_USER_STREAM_INDEX_MIMETYPE; +// else +// mimetype = "application/octet-stream"; + + char tmpstr[150]; + //adding file size + if (file->attributes & FILE_ATTRIBUTE_DIRECTORY) { + //mimetype = GUAC_USER_STREAM_INDEX_MIMETYPE; + sprintf(tmpstr, "{\"mime\":\"%s\",\"size\":%lu}", + GUAC_USER_STREAM_INDEX_MIMETYPE, file->size); + } + else { + //mimetype = "application/octet-stream"; + sprintf(tmpstr, "{\"mime\":\"%s\",\"size\":%lu}", + "application/octet-stream", file->size); + } + mimetype = tmpstr; /* Write entry */ blob_written |= guac_common_json_write_property(user, stream, From e6c1c2b12d5a6e527d32322fe44b3cd4a052791b Mon Sep 17 00:00:00 2001 From: bookread-he <54766287+bookread-he@users.noreply.github.com> Date: Fri, 11 Feb 2022 15:51:35 +0800 Subject: [PATCH 2/5] Update sftp.c --- src/common-ssh/sftp.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/common-ssh/sftp.c b/src/common-ssh/sftp.c index e91e72d301..9d835fef2b 100644 --- a/src/common-ssh/sftp.c +++ b/src/common-ssh/sftp.c @@ -660,19 +660,19 @@ static int guac_common_ssh_sftp_ls_ack_handler(guac_user* user, //adding file size and permission char tmpstr[150]; - if (LIBSSH2_SFTP_S_ISDIR(attributes.permissions)) { - //mimetype = GUAC_USER_STREAM_INDEX_MIMETYPE; - sprintf(tmpstr, "{\"mime\":\"%s\",\"size\":%llu,\"perm\":%lu}", - GUAC_USER_STREAM_INDEX_MIMETYPE, attributes.filesize, - attributes.permissions); - } - else { - //mimetype = "application/octet-stream"; - sprintf(tmpstr, "{\"mime\":\"%s\",\"size\":%llu,\"perm\":%lu}", - "application/octet-stream", attributes.filesize, - attributes.permissions); - } - mimetype = tmpstr; + if (LIBSSH2_SFTP_S_ISDIR(attributes.permissions)) { + //mimetype = GUAC_USER_STREAM_INDEX_MIMETYPE; + sprintf(tmpstr, "{\"mime\":\"%s\",\"size\":%llu,\"perm\":%lu}", + GUAC_USER_STREAM_INDEX_MIMETYPE, attributes.filesize, + attributes.permissions); + } + else { + //mimetype = "application/octet-stream"; + sprintf(tmpstr, "{\"mime\":\"%s\",\"size\":%llu,\"perm\":%lu}", + "application/octet-stream", attributes.filesize, + attributes.permissions); + } + mimetype = tmpstr; /* Write entry, waiting for next ack if a blob is written */ if (guac_common_json_write_property(user, stream, From 4c7d49a73ff45cf1cc59ae45cae5701e4b792026 Mon Sep 17 00:00:00 2001 From: bookread-he <54766287+bookread-he@users.noreply.github.com> Date: Fri, 11 Feb 2022 16:12:38 +0800 Subject: [PATCH 3/5] Update sftp.c --- src/common-ssh/sftp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common-ssh/sftp.c b/src/common-ssh/sftp.c index 9d835fef2b..9303cdaa94 100644 --- a/src/common-ssh/sftp.c +++ b/src/common-ssh/sftp.c @@ -32,6 +32,7 @@ #include #include #include +#include int guac_common_ssh_sftp_normalize_path(char* fullpath, const char* path) { From 3f9e19de093be22d9c3e5d85c3ffe321846e0a65 Mon Sep 17 00:00:00 2001 From: bookread-he <54766287+bookread-he@users.noreply.github.com> Date: Fri, 11 Feb 2022 16:13:12 +0800 Subject: [PATCH 4/5] Update ls.c --- src/protocols/rdp/ls.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/protocols/rdp/ls.c b/src/protocols/rdp/ls.c index b117af3feb..09e86166bf 100644 --- a/src/protocols/rdp/ls.c +++ b/src/protocols/rdp/ls.c @@ -30,6 +30,7 @@ #include #include +#include int guac_rdp_ls_ack_handler(guac_user* user, guac_stream* stream, char* message, guac_protocol_status status) { From e8d367d2325fe379f079d8034083f1411e14ed57 Mon Sep 17 00:00:00 2001 From: bookread-he <54766287+bookread-he@users.noreply.github.com> Date: Fri, 11 Feb 2022 18:38:40 +0800 Subject: [PATCH 5/5] GUACAMOLE-1536: return file size and file permission information when uploading files and displaying file directories (#2) * Update sftp.c remove invalid annotation * Update ls.c remove invalid annotation --- src/common-ssh/sftp.c | 7 ------- src/protocols/rdp/ls.c | 7 ------- 2 files changed, 14 deletions(-) diff --git a/src/common-ssh/sftp.c b/src/common-ssh/sftp.c index 9303cdaa94..a3eab54c91 100644 --- a/src/common-ssh/sftp.c +++ b/src/common-ssh/sftp.c @@ -654,21 +654,14 @@ static int guac_common_ssh_sftp_ls_ack_handler(guac_user* user, /* Determine mimetype */ const char* mimetype; -// if (LIBSSH2_SFTP_S_ISDIR(attributes.permissions)) -// mimetype = GUAC_USER_STREAM_INDEX_MIMETYPE; -// else -// mimetype = "application/octet-stream"; - //adding file size and permission char tmpstr[150]; if (LIBSSH2_SFTP_S_ISDIR(attributes.permissions)) { - //mimetype = GUAC_USER_STREAM_INDEX_MIMETYPE; sprintf(tmpstr, "{\"mime\":\"%s\",\"size\":%llu,\"perm\":%lu}", GUAC_USER_STREAM_INDEX_MIMETYPE, attributes.filesize, attributes.permissions); } else { - //mimetype = "application/octet-stream"; sprintf(tmpstr, "{\"mime\":\"%s\",\"size\":%llu,\"perm\":%lu}", "application/octet-stream", attributes.filesize, attributes.permissions); diff --git a/src/protocols/rdp/ls.c b/src/protocols/rdp/ls.c index 09e86166bf..3181e01023 100644 --- a/src/protocols/rdp/ls.c +++ b/src/protocols/rdp/ls.c @@ -86,20 +86,13 @@ int guac_rdp_ls_ack_handler(guac_user* user, guac_stream* stream, /* Determine mimetype */ const char* mimetype; -// if (file->attributes & FILE_ATTRIBUTE_DIRECTORY) -// mimetype = GUAC_USER_STREAM_INDEX_MIMETYPE; -// else -// mimetype = "application/octet-stream"; - char tmpstr[150]; //adding file size if (file->attributes & FILE_ATTRIBUTE_DIRECTORY) { - //mimetype = GUAC_USER_STREAM_INDEX_MIMETYPE; sprintf(tmpstr, "{\"mime\":\"%s\",\"size\":%lu}", GUAC_USER_STREAM_INDEX_MIMETYPE, file->size); } else { - //mimetype = "application/octet-stream"; sprintf(tmpstr, "{\"mime\":\"%s\",\"size\":%lu}", "application/octet-stream", file->size); }