0
0
Fork 0
mirror of https://github.com/atmoz/sftp.git synced 2024-11-17 12:51:33 -05:00

Allow comments in users.conf

This commit is contained in:
Adrian Dvergsdal 2017-10-08 19:08:53 +02:00
parent ce4a480b3e
commit f315792bd7
2 changed files with 6 additions and 1 deletions

View file

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

View file

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