0
0
Fork 0
mirror of https://github.com/atmoz/sftp.git synced 2024-11-24 12:59:24 -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='[^:]*' reDir='[^:]*'
reArgs="^($reUser)(:$rePass)(:e)?(:$reUid)?(:$reGid)?(:$reDir)?$" reArgs="^($reUser)(:$rePass)(:e)?(:$reUid)?(:$reGid)?(:$reDir)?$"
reArgsMaybe="^[^:[:space:]]+:.*$" # Smallest indication of attempt to use argument reArgsMaybe="^[^:[:space:]]+:.*$" # Smallest indication of attempt to use argument
reArgSkip='^([[:blank:]]*#.*|[[:blank:]]*)$' # comment or empty line
function log() { function log() {
echo "[entrypoint] $@" echo "[entrypoint] $@"
@ -126,7 +127,7 @@ if [ ! -f "$userConfFinalPath" ]; then
# Append mounted config to final config # Append mounted config to final config
if [ -f "$userConfPath" ]; then if [ -f "$userConfPath" ]; then
cat "$userConfPath" | grep -v -e '^$' > "$userConfFinalPath" cat "$userConfPath" | grep -v -E "$reArgSkip" > "$userConfFinalPath"
fi fi
# Append users from STDIN to final config # Append users from STDIN to final config

View file

@ -44,6 +44,10 @@ function beforeTest() {
mkdir "$tmpDir" mkdir "$tmpDir"
echo "test::$(id -u):$(id -g):dir1,dir2" >> "$tmpDir/users" 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" echo "user.with.dot::$(id -u):$(id -g)" >> "$tmpDir/users"
$sudo docker run \ $sudo docker run \
-v "$tmpDir/users:/etc/sftp/users.conf:ro" \ -v "$tmpDir/users:/etc/sftp/users.conf:ro" \