You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2017/07/03 21:52:10 UTC

[2/3] incubator-guacamole-server git commit: GUACAMOLE-303: Add "sftp-root-directory" parameter to VNC, RDP, and SSH.

GUACAMOLE-303: Add "sftp-root-directory" parameter to VNC, RDP, and SSH.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/commit/d51e92eb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/d51e92eb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/d51e92eb

Branch: refs/heads/master
Commit: d51e92eb312735ec857e7ede0a202728ae9dcb26
Parents: 0474f86
Author: Michael Jumper <mj...@apache.org>
Authored: Thu Jun 29 15:48:23 2017 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Thu Jun 29 15:48:23 2017 -0700

----------------------------------------------------------------------
 src/protocols/rdp/rdp.c          |  4 ++--
 src/protocols/rdp/rdp_settings.c | 13 +++++++++++++
 src/protocols/rdp/rdp_settings.h |  6 ++++++
 src/protocols/ssh/settings.c     | 15 +++++++++++++++
 src/protocols/ssh/settings.h     |  6 ++++++
 src/protocols/ssh/ssh.c          |  3 ++-
 src/protocols/vnc/settings.c     | 13 +++++++++++++
 src/protocols/vnc/settings.h     |  6 ++++++
 src/protocols/vnc/vnc.c          |  4 ++--
 9 files changed, 65 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/d51e92eb/src/protocols/rdp/rdp.c
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c
index c1be71e..0b15d05 100644
--- a/src/protocols/rdp/rdp.c
+++ b/src/protocols/rdp/rdp.c
@@ -987,8 +987,8 @@ void* guac_rdp_client_thread(void* data) {
 
         /* Load and expose filesystem */
         rdp_client->sftp_filesystem =
-            guac_common_ssh_create_sftp_filesystem(
-                    rdp_client->sftp_session, "/", NULL);
+            guac_common_ssh_create_sftp_filesystem(rdp_client->sftp_session,
+                    settings->sftp_root_directory, NULL);
 
         /* Expose filesystem to connection owner */
         guac_client_for_owner(client,

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/d51e92eb/src/protocols/rdp/rdp_settings.c
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/rdp_settings.c b/src/protocols/rdp/rdp_settings.c
index f73ef9d..57e6016 100644
--- a/src/protocols/rdp/rdp_settings.c
+++ b/src/protocols/rdp/rdp_settings.c
@@ -84,6 +84,7 @@ const char* GUAC_RDP_CLIENT_ARGS[] = {
     "sftp-private-key",
     "sftp-passphrase",
     "sftp-directory",
+    "sftp-root-directory",
     "sftp-server-alive-interval",
 #endif
 
@@ -368,6 +369,12 @@ enum RDP_ARGS_IDX {
     IDX_SFTP_DIRECTORY,
 
     /**
+     * The path of the directory within the SSH server to expose as a
+     * filesystem guac_object. If omitted, "/" will be used by default.
+     */
+    IDX_SFTP_ROOT_DIRECTORY,
+
+    /**
      * The interval at which SSH keepalive messages are sent to the server for
      * SFTP connections.  The default is 0 (disabling keepalives), and a value
      * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner
@@ -784,6 +791,11 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user,
         guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv,
                 IDX_SFTP_DIRECTORY, NULL);
 
+    /* SFTP root directory */
+    settings->sftp_root_directory =
+        guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv,
+                IDX_SFTP_ROOT_DIRECTORY, "/");
+
     /* Default keepalive value */
     settings->sftp_server_alive_interval =
         guac_user_parse_args_int(user, GUAC_RDP_CLIENT_ARGS, argv,
@@ -909,6 +921,7 @@ void guac_rdp_settings_free(guac_rdp_settings* settings) {
 #ifdef ENABLE_COMMON_SSH
     /* Free SFTP settings */
     free(settings->sftp_directory);
+    free(settings->sftp_root_directory);
     free(settings->sftp_hostname);
     free(settings->sftp_passphrase);
     free(settings->sftp_password);

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/d51e92eb/src/protocols/rdp/rdp_settings.h
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/rdp_settings.h b/src/protocols/rdp/rdp_settings.h
index 8edb79e..ec540ef 100644
--- a/src/protocols/rdp/rdp_settings.h
+++ b/src/protocols/rdp/rdp_settings.h
@@ -361,6 +361,12 @@ typedef struct guac_rdp_settings {
     char* sftp_directory;
 
     /**
+     * The path of the directory within the SSH server to expose as a
+     * filesystem guac_object.
+     */
+    char* sftp_root_directory;
+
+    /**
      * The interval at which SSH keepalive messages are sent to the server for
      * SFTP connections.  The default is 0 (disabling keepalives), and a value
      * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/d51e92eb/src/protocols/ssh/settings.c
----------------------------------------------------------------------
diff --git a/src/protocols/ssh/settings.c b/src/protocols/ssh/settings.c
index 8843923..832dcfa 100644
--- a/src/protocols/ssh/settings.c
+++ b/src/protocols/ssh/settings.c
@@ -37,6 +37,7 @@ const char* GUAC_SSH_CLIENT_ARGS[] = {
     "font-name",
     "font-size",
     "enable-sftp",
+    "sftp-root-directory",
     "private-key",
     "passphrase",
 #ifdef ENABLE_SSH_AGENT
@@ -93,6 +94,12 @@ enum SSH_ARGS_IDX {
     IDX_ENABLE_SFTP,
 
     /**
+     * The path of the directory within the SSH server to expose as a
+     * filesystem guac_object. If omitted, "/" will be used by default.
+     */
+    IDX_SFTP_ROOT_DIRECTORY,
+
+    /**
      * The private key to use for authentication, if any.
      */
     IDX_PRIVATE_KEY,
@@ -236,6 +243,11 @@ guac_ssh_settings* guac_ssh_parse_args(guac_user* user,
         guac_user_parse_args_boolean(user, GUAC_SSH_CLIENT_ARGS, argv,
                 IDX_ENABLE_SFTP, false);
 
+    /* SFTP root directory */
+    settings->sftp_root_directory =
+        guac_user_parse_args_string(user, GUAC_SSH_CLIENT_ARGS, argv,
+                IDX_SFTP_ROOT_DIRECTORY, "/");
+
 #ifdef ENABLE_SSH_AGENT
     settings->enable_agent =
         guac_user_parse_args_boolean(user, GUAC_SSH_CLIENT_ARGS, argv,
@@ -316,6 +328,9 @@ void guac_ssh_settings_free(guac_ssh_settings* settings) {
     /* Free requested command */
     free(settings->command);
 
+    /* Free SFTP settings */
+    free(settings->sftp_root_directory);
+
     /* Free typescript settings */
     free(settings->typescript_name);
     free(settings->typescript_path);

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/d51e92eb/src/protocols/ssh/settings.h
----------------------------------------------------------------------
diff --git a/src/protocols/ssh/settings.h b/src/protocols/ssh/settings.h
index f49d054..f093023 100644
--- a/src/protocols/ssh/settings.h
+++ b/src/protocols/ssh/settings.h
@@ -145,6 +145,12 @@ typedef struct guac_ssh_settings {
      */
     bool enable_sftp;
 
+    /**
+     * The path of the directory within the SSH server to expose as a
+     * filesystem guac_object.
+     */
+    char* sftp_root_directory;
+
 #ifdef ENABLE_SSH_AGENT
     /**
      * Whether the SSH agent is enabled.

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/d51e92eb/src/protocols/ssh/ssh.c
----------------------------------------------------------------------
diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c
index 18a0dcb..b9bb59b 100644
--- a/src/protocols/ssh/ssh.c
+++ b/src/protocols/ssh/ssh.c
@@ -266,7 +266,8 @@ void* ssh_client_thread(void* data) {
 
         /* Request SFTP */
         ssh_client->sftp_filesystem = guac_common_ssh_create_sftp_filesystem(
-                    ssh_client->sftp_session, "/", NULL);
+                    ssh_client->sftp_session, settings->sftp_root_directory,
+                    NULL);
 
         /* Expose filesystem to connection owner */
         guac_client_for_owner(client,

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/d51e92eb/src/protocols/vnc/settings.c
----------------------------------------------------------------------
diff --git a/src/protocols/vnc/settings.c b/src/protocols/vnc/settings.c
index 697466d..0bcd5ab 100644
--- a/src/protocols/vnc/settings.c
+++ b/src/protocols/vnc/settings.c
@@ -66,6 +66,7 @@ const char* GUAC_VNC_CLIENT_ARGS[] = {
     "sftp-private-key",
     "sftp-passphrase",
     "sftp-directory",
+    "sftp-root-directory",
     "sftp-server-alive-interval",
 #endif
 
@@ -230,6 +231,12 @@ enum VNC_ARGS_IDX {
     IDX_SFTP_DIRECTORY,
 
     /**
+     * The path of the directory within the SSH server to expose as a
+     * filesystem guac_object. If omitted, "/" will be used by default.
+     */
+    IDX_SFTP_ROOT_DIRECTORY,
+
+    /**
      * The interval at which SSH keepalive messages are sent to the server for
      * SFTP connections.  The default is 0 (disabling keepalives), and a value
      * of 1 is automatically incremented to 2 by libssh2 to avoid busy loop corner
@@ -405,6 +412,11 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user,
         guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv,
                 IDX_SFTP_DIRECTORY, NULL);
 
+    /* SFTP root directory */
+    settings->sftp_root_directory =
+        guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv,
+                IDX_SFTP_ROOT_DIRECTORY, "/");
+
     /* Default keepalive value */
     settings->sftp_server_alive_interval =
         guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv,
@@ -447,6 +459,7 @@ void guac_vnc_settings_free(guac_vnc_settings* settings) {
 #ifdef ENABLE_COMMON_SSH
     /* Free SFTP settings */
     free(settings->sftp_directory);
+    free(settings->sftp_root_directory);
     free(settings->sftp_hostname);
     free(settings->sftp_passphrase);
     free(settings->sftp_password);

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/d51e92eb/src/protocols/vnc/settings.h
----------------------------------------------------------------------
diff --git a/src/protocols/vnc/settings.h b/src/protocols/vnc/settings.h
index 3c7b258..4fa8eb4 100644
--- a/src/protocols/vnc/settings.h
+++ b/src/protocols/vnc/settings.h
@@ -175,6 +175,12 @@ typedef struct guac_vnc_settings {
     char* sftp_directory;
 
     /**
+     * The path of the directory within the SSH server to expose as a
+     * filesystem guac_object.
+     */
+    char* sftp_root_directory;
+
+    /**
      * The interval at which SSH keepalive messages are sent to the server for
      * SFTP connections.  The default is 0 (disabling keepalives), and a value
      * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/d51e92eb/src/protocols/vnc/vnc.c
----------------------------------------------------------------------
diff --git a/src/protocols/vnc/vnc.c b/src/protocols/vnc/vnc.c
index 2b7263a..38c7cd6 100644
--- a/src/protocols/vnc/vnc.c
+++ b/src/protocols/vnc/vnc.c
@@ -271,8 +271,8 @@ void* guac_vnc_client_thread(void* data) {
 
         /* Load filesystem */
         vnc_client->sftp_filesystem =
-            guac_common_ssh_create_sftp_filesystem(
-                    vnc_client->sftp_session, "/", NULL);
+            guac_common_ssh_create_sftp_filesystem(vnc_client->sftp_session,
+                    settings->sftp_root_directory, NULL);
 
         /* Expose filesystem to connection owner */
         guac_client_for_owner(client,