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:
parent
ce4a480b3e
commit
f315792bd7
2 changed files with 6 additions and 1 deletions
|
@ -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
|
||||||
|
|
|
@ -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" \
|
||||||
|
|
Loading…
Reference in a new issue