From 2a98e037bb4b0c67f7decb7df8cc078c8e422e95 Mon Sep 17 00:00:00 2001 From: PlusMinus0 Date: Thu, 22 Nov 2018 10:11:53 +0100 Subject: [PATCH] Fix case where UID and GID are passed and added a test for that case. --- .gitignore | 3 ++- build-n-test.sh | 5 +++++ common/entrypoint.sh | 4 ++-- goss-default.yaml | 37 +++++++++++++++++++++++++++++++++++++ goss-uid-test.yaml | 9 +++++++++ goss.yaml | 25 +++---------------------- 6 files changed, 58 insertions(+), 25 deletions(-) create mode 100644 goss-default.yaml create mode 100644 goss-uid-test.yaml diff --git a/.gitignore b/.gitignore index 4c06dab..73d6ef0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *\~ .\#* \#*\# -.config/ \ No newline at end of file +.config/ +goss.yaml \ No newline at end of file diff --git a/build-n-test.sh b/build-n-test.sh index f177150..3d0a77d 100755 --- a/build-n-test.sh +++ b/build-n-test.sh @@ -15,7 +15,12 @@ for image in "${images[@]}"; do docker build -t $tag -f $image.Dockerfile . echo "Testing image" + cp goss-default.yaml goss.yaml dgoss run $tag + + echo "Testing again with UID and GID" + cp goss-uid-test.yaml goss.yaml + dgoss run -e UID=1001 -e GID=101 $tag done diff --git a/common/entrypoint.sh b/common/entrypoint.sh index f6d4282..6f2f589 100755 --- a/common/entrypoint.sh +++ b/common/entrypoint.sh @@ -1,8 +1,8 @@ #!/bin/sh # Set defaults for uid and gid to not be root -if [ -n $GID ]; then GID=100; fi -if [ -n $UID ]; then UID=1000; fi +if [ -z $GID ]; then GID=100; fi +if [ -z $UID ]; then UID=1000; fi if [ "$GID" -ne "0" ]; then GROUP=jdownloader diff --git a/goss-default.yaml b/goss-default.yaml new file mode 100644 index 0000000..edae253 --- /dev/null +++ b/goss-default.yaml @@ -0,0 +1,37 @@ +file: + /opt/JDownloader/JDownloader.jar: + exists: true + mode: + or: + - "0664" + - "0644" + filetype: file + contains: [] + /opt/JDownloader/sevenzipjbinding1509.jar: + exists: true + mode: + or: + - "0664" + - "0644" + filetype: file + contains: [] + /opt/JDownloader/sevenzipjbinding1509Linux.jar: + exists: true + mode: + or: + - "0664" + - "0644" + filetype: file + contains: [] +package: + ffmpeg: + installed: true +user: + jdownloader: + exists: true + uid: 1000 + gid: 100 + groups: + - users + home: [] + shell: /bin/false diff --git a/goss-uid-test.yaml b/goss-uid-test.yaml new file mode 100644 index 0000000..12757b7 --- /dev/null +++ b/goss-uid-test.yaml @@ -0,0 +1,9 @@ +user: + jdownloader: + exists: true + uid: 1001 + gid: 101 + groups: + - jdownloader + home: [] + shell: /bin/false diff --git a/goss.yaml b/goss.yaml index 5fadbc4..12757b7 100644 --- a/goss.yaml +++ b/goss.yaml @@ -1,28 +1,9 @@ -file: - /opt/JDownloader/JDownloader.jar: - exists: true - mode: "0644" - filetype: file - contains: [] - /opt/JDownloader/sevenzipjbinding1509.jar: - exists: true - mode: "0664" - filetype: file - contains: [] - /opt/JDownloader/sevenzipjbinding1509Linux.jar: - exists: true - mode: "0664" - filetype: file - contains: [] -package: - ffmpeg: - installed: true user: jdownloader: exists: true - uid: 1000 - gid: 100 + uid: 1001 + gid: 101 groups: - - users + - jdownloader home: [] shell: /bin/false