From f315792bd7e3733b9694f9ad2d7167f2c19e03ef Mon Sep 17 00:00:00 2001 From: Adrian Dvergsdal Date: Sun, 8 Oct 2017 19:08:53 +0200 Subject: [PATCH] Allow comments in users.conf --- entrypoint | 3 ++- tests/run | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/entrypoint b/entrypoint index c1cd24e..d3a528f 100755 --- a/entrypoint +++ b/entrypoint @@ -14,6 +14,7 @@ reGid='[[:digit:]]*' reDir='[^:]*' reArgs="^($reUser)(:$rePass)(:e)?(:$reUid)?(:$reGid)?(:$reDir)?$" reArgsMaybe="^[^:[:space:]]+:.*$" # Smallest indication of attempt to use argument +reArgSkip='^([[:blank:]]*#.*|[[:blank:]]*)$' # comment or empty line function log() { echo "[entrypoint] $@" @@ -126,7 +127,7 @@ if [ ! -f "$userConfFinalPath" ]; then # Append mounted config to final config if [ -f "$userConfPath" ]; then - cat "$userConfPath" | grep -v -e '^$' > "$userConfFinalPath" + cat "$userConfPath" | grep -v -E "$reArgSkip" > "$userConfFinalPath" fi # Append users from STDIN to final config diff --git a/tests/run b/tests/run index 95ed8bb..0453473 100755 --- a/tests/run +++ b/tests/run @@ -44,6 +44,10 @@ function beforeTest() { mkdir "$tmpDir" echo "test::$(id -u):$(id -g):dir1,dir2" >> "$tmpDir/users" + echo "" >> "$tmpDir/users" # empty line + echo "# comments are allowed" >> "$tmpDir/users" + echo " " >> "$tmpDir/users" # only whitespace + echo " # with whitespace in front" >> "$tmpDir/users" echo "user.with.dot::$(id -u):$(id -g)" >> "$tmpDir/users" $sudo docker run \ -v "$tmpDir/users:/etc/sftp/users.conf:ro" \