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] 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 <