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" \