From f66c81f351e4cebec8599669363c855a4a1c80ee Mon Sep 17 00:00:00 2001 From: Jean-Benoit Paux <9682558+jbpaux@users.noreply.github.com> Date: Thu, 16 Sep 2021 10:38:47 +0200 Subject: [PATCH 1/4] GUACAMOLE-1418: Add support of SQL Server JDBC plugin in Docker Image --- guacamole-docker/README.md | 65 +++++++++- guacamole-docker/bin/build-guacamole.sh | 14 +++ guacamole-docker/bin/initdb.sh | 8 +- guacamole-docker/bin/start.sh | 153 +++++++++++++++++++++++- 4 files changed, 229 insertions(+), 11 deletions(-) diff --git a/guacamole-docker/README.md b/guacamole-docker/README.md index f7b7abe4c..606269f16 100644 --- a/guacamole-docker/README.md +++ b/guacamole-docker/README.md @@ -13,7 +13,7 @@ How to use this image Using this image will require an existing, running Docker container with the [guacd image](https://registry.hub.docker.com/u/guacamole/guacd/), and another -Docker container providing either a PostgreSQL or MySQL database. +Docker container providing either a PostgreSQL, MySQL or SQLServer database. The name of the database and all associated credentials are specified with environment variables given when the container is created. All other @@ -31,9 +31,9 @@ Docker, as well. Docker Secrets ============== The string `_FILE` may be appended to some of the environment variables listed -below if you are using MySQL or PostgreSQL authentication. This will cause the -startup script to load the values for those variables from files within -the container. +below if you are using MySQL, PostgreSQL or SQLServer authentication. This will +cause the startup script to load the values for those variables from files +within the container. This is useful for specifying sensitive info, ie. passwords for the database, in secured files instead of plaintext environment variables. This @@ -163,6 +163,63 @@ The process for doing this via the `mysql` utility included with MySQL is documented in [the Guacamole manual](http://guacamole.apache.org/doc/gug/jdbc-auth.html#jdbc-auth-mysql). +Deploying Guacamole with SQLServer authentication +-------------------------------------------------- + + docker run --name some-guacamole --link some-guacd:guacd \ + --link some-sqlserver:sqlserver \ + -e SQLSERVER_DATABASE=guacamole_db \ + -e SQLSERVER_USER=guacamole_user \ + -e SQLSERVER_PASSWORD=some_password \ + -e SQLSERVER_DATABASE_FILE=/run/secrets/ \ + -e SQLSERVER_USER_FILE=/run/secrets/ \ + -e SQLSERVER_PASSWORD_FILE=/run/secrets/ \ + -d -p 8080:8080 guacamole/guacamole + +Linking Guacamole to SQLServer requires three environment variables. If any of +these environment variables are omitted, you will receive an error message, and +the image will stop: + +1. `SQLSERVER_DATABASE` - The name of the database to use for Guacamole + authentication. +2. `SQLSERVER_USER` - The user that Guacamole will use to connect to SQLServer. +3. `SQLSERVER_PASSWORD` - The password that Guacamole will provide when + connecting to SQLServer as `SQLSERVER_USER`. +4. `SQLSERVER_DATABASE_FILE` - The path of the docker secret containing the name + of database to use for Guacamole authentication. +5. `SQLSERVER_USER_FILE` - The path of the docker secret containing the name of + the user that Guacamole will use to connect to SQLServer. +6. `SQLSERVER_PASSWORD_FILE` - The path of the docker secret containing the + password that Guacamole will provide when connecting to SQLServer as + `SQLSERVER_USER. + +### Initializing the SQLServer database + +If your database is not already initialized with the Guacamole schema, you will +need to do so prior to using Guacamole. A convenience script for generating the +necessary SQL to do this is included in the Guacamole image. + +To generate a SQL script which can be used to initialize a fresh SQLServer +database +[as documented in the Guacamole manual](http://guacamole.apache.org/doc/gug/jdbc-auth.html#jdbc-auth-sqlserver): + + docker run --rm guacamole/guacamole /opt/guacamole/bin/initdb.sh --sqlserver > initdb.sql + +Alternatively, you can use the SQL scripts included with the +guacamole-auth-jdbc extension from +[the corresponding release](http://guacamole.apache.org/releases/). + +Once this script is generated, you must: + +1. Create a database for Guacamole within SQLServer, such as `guacamole_db`. +2. Run the script on the newly-created database. +3. Create a user for Guacamole within SQLServer with access to the tables and + sequences of this database, such as `guacamole_user`. + +The process for doing this via the `sqlcmd` utilities included +with SQLServer is documented in +[the Guacamole manual](http://guacamole.apache.org/doc/gug/jdbc-auth.html#jdbc-auth-sqlserver). + Reporting issues ================ diff --git a/guacamole-docker/bin/build-guacamole.sh b/guacamole-docker/bin/build-guacamole.sh index d3f6741ac..5efaa3e60 100755 --- a/guacamole-docker/bin/build-guacamole.sh +++ b/guacamole-docker/bin/build-guacamole.sh @@ -110,6 +110,20 @@ tar -xz \ echo "Downloading PostgreSQL JDBC driver ..." curl -L "https://jdbc.postgresql.org/download/postgresql-9.4-1201.jdbc41.jar" > "$DESTINATION/postgresql/postgresql-9.4-1201.jdbc41.jar" +# +# Download SQL Server JDBC driver +# + +echo "Downloading SQL Server JDBC driver ..." +curl -L "https://go.microsoft.com/fwlink/?linkid=2168494&clcid=0x409" | \ +tar -xz \ + -C "$DESTINATION/sqlserver/" \ + --wildcards \ + --no-anchored \ + --no-wildcards-match-slash \ + --strip-components=2 \ + "mssql-jdbc-*.jre8.jar" + # # Copy LDAP auth extension and schema modifications # diff --git a/guacamole-docker/bin/initdb.sh b/guacamole-docker/bin/initdb.sh index f56da7467..6031189c9 100755 --- a/guacamole-docker/bin/initdb.sh +++ b/guacamole-docker/bin/initdb.sh @@ -26,7 +26,7 @@ ## ## @param DATABASE ## The database to generate the SQL script for. This may be either -## "--postgres", for PostgreSQL, or "--mysql" for MySQL. +## "--postgres", for PostgreSQL, "--mysql" for MySQL, or "--sqlserver" for Microsoft SQL Server. ## DATABASE="$1" @@ -37,7 +37,7 @@ DATABASE="$1" ## incorrect_usage() { cat < Date: Fri, 24 Dec 2021 17:13:23 +0100 Subject: [PATCH 2/4] GUACAMOLE-1418: Make use of secrets files clearer --- guacamole-docker/README.md | 34 +++++++++++++++++++++------------- guacamole-docker/bin/start.sh | 18 +++++++++++++++--- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/guacamole-docker/README.md b/guacamole-docker/README.md index 606269f16..0f6200f89 100644 --- a/guacamole-docker/README.md +++ b/guacamole-docker/README.md @@ -166,16 +166,6 @@ documented in Deploying Guacamole with SQLServer authentication -------------------------------------------------- - docker run --name some-guacamole --link some-guacd:guacd \ - --link some-sqlserver:sqlserver \ - -e SQLSERVER_DATABASE=guacamole_db \ - -e SQLSERVER_USER=guacamole_user \ - -e SQLSERVER_PASSWORD=some_password \ - -e SQLSERVER_DATABASE_FILE=/run/secrets/ \ - -e SQLSERVER_USER_FILE=/run/secrets/ \ - -e SQLSERVER_PASSWORD_FILE=/run/secrets/ \ - -d -p 8080:8080 guacamole/guacamole - Linking Guacamole to SQLServer requires three environment variables. If any of these environment variables are omitted, you will receive an error message, and the image will stop: @@ -185,14 +175,32 @@ the image will stop: 2. `SQLSERVER_USER` - The user that Guacamole will use to connect to SQLServer. 3. `SQLSERVER_PASSWORD` - The password that Guacamole will provide when connecting to SQLServer as `SQLSERVER_USER`. -4. `SQLSERVER_DATABASE_FILE` - The path of the docker secret containing the name + + docker run --name some-guacamole --link some-guacd:guacd \ + --link some-sqlserver:sqlserver \ + -e SQLSERVER_DATABASE=guacamole_db \ + -e SQLSERVER_USER=guacamole_user \ + -e SQLSERVER_PASSWORD=some_password \ + -d -p 8080:8080 guacamole/guacamole + +Alternatively, if you want to store database credentials using Docker secrets, +the following three variables are required and replace the previous three: + +1. `SQLSERVER_DATABASE_FILE` - The path of the docker secret containing the name of database to use for Guacamole authentication. -5. `SQLSERVER_USER_FILE` - The path of the docker secret containing the name of +2. `SQLSERVER_USER_FILE` - The path of the docker secret containing the name of the user that Guacamole will use to connect to SQLServer. -6. `SQLSERVER_PASSWORD_FILE` - The path of the docker secret containing the +3. `SQLSERVER_PASSWORD_FILE` - The path of the docker secret containing the password that Guacamole will provide when connecting to SQLServer as `SQLSERVER_USER. + docker run --name some-guacamole --link some-guacd:guacd \ + --link some-sqlserver:sqlserver \ + -e SQLSERVER_DATABASE_FILE=/run/secrets/ \ + -e SQLSERVER_USER_FILE=/run/secrets/ \ + -e SQLSERVER_PASSWORD_FILE=/run/secrets/ \ + -d -p 8080:8080 guacamole/guacamole + ### Initializing the SQLServer database If your database is not already initialized with the Guacamole schema, you will diff --git a/guacamole-docker/bin/start.sh b/guacamole-docker/bin/start.sh index 74497f37b..acd4ada99 100755 --- a/guacamole-docker/bin/start.sh +++ b/guacamole-docker/bin/start.sh @@ -409,9 +409,7 @@ sqlserver_missing_vars() { FATAL: Missing required environment variables ------------------------------------------------------------------------------- If using a SQLServer database, you must provide each of the following -environment variables or their corresponding Docker secrets by appending _FILE -to the environment variable, and setting the value to the path of the -corresponding secret: +environment variables: SQLSERVER_USER The user to authenticate as when connecting to SQLServer. @@ -421,6 +419,20 @@ corresponding secret: SQLSERVER_DATABASE The name of the SQLServer database to use for Guacamole authentication. + +Alternatively, if you want to store database credentials using Docker secrets, +set the path of the corresponding secrets in the following three variables: + + SQLSERVER_DATABASE_FILE The path of the docker secret containing the name + of database to use for Guacamole authentication. + + SQLSERVER_USER_FILE The path of the docker secret containing the name of + the user that Guacamole will use to connect to SQLServer. + + SQLSERVER_PASSWORD_FILE The path of the docker secret containing the + password that Guacamole will provide when connecting to + SQLServer as SQLSERVER_USER. + END exit 1; } From c6eeeab56077f61f21112460da760d3da7b0996d Mon Sep 17 00:00:00 2001 From: jbpaux <9682558+jbpaux@users.noreply.github.com> Date: Sat, 25 Dec 2021 22:36:17 +0100 Subject: [PATCH 3/4] GUACAMOLE-1418: fix missing space --- guacamole-docker/bin/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guacamole-docker/bin/start.sh b/guacamole-docker/bin/start.sh index acd4ada99..b87c66b04 100755 --- a/guacamole-docker/bin/start.sh +++ b/guacamole-docker/bin/start.sh @@ -23,7 +23,7 @@ ## ## Automatically configures and starts Guacamole under Tomcat. Guacamole's ## guacamole.properties file will be automatically generated based on the -## linked database container (either MySQL,PostgreSQL or SQLServer) and the linked guacd +## linked database container (either MySQL, PostgreSQL or SQLServer) and the linked guacd ## container. The Tomcat process will ultimately replace the process of this ## script, running in the foreground until terminated. ## From 42f753bda8ddbbdfc1fbbe7ecf527cbb804dae01 Mon Sep 17 00:00:00 2001 From: jbpaux <9682558+jbpaux@users.noreply.github.com> Date: Sat, 25 Dec 2021 22:40:26 +0100 Subject: [PATCH 4/4] GUACAMOLE-1418: update SQL Server driver to 9.4.1 --- guacamole-docker/bin/build-guacamole.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guacamole-docker/bin/build-guacamole.sh b/guacamole-docker/bin/build-guacamole.sh index 5efaa3e60..41807d9ac 100755 --- a/guacamole-docker/bin/build-guacamole.sh +++ b/guacamole-docker/bin/build-guacamole.sh @@ -115,7 +115,7 @@ curl -L "https://jdbc.postgresql.org/download/postgresql-9.4-1201.jdbc41.jar" > # echo "Downloading SQL Server JDBC driver ..." -curl -L "https://go.microsoft.com/fwlink/?linkid=2168494&clcid=0x409" | \ +curl -L "https://go.microsoft.com/fwlink/?linkid=2183223&clcid=0x409" | \ tar -xz \ -C "$DESTINATION/sqlserver/" \ --wildcards \