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

Fix dir for loop

This commit is contained in:
Adrian Dvergsdal 2016-08-12 20:45:21 +02:00
parent d4a108f53a
commit d961e18d73
3 changed files with 18 additions and 14 deletions

View file

@ -97,7 +97,7 @@ Tip: you can use [atmoz/makepasswd](https://hub.docker.com/r/atmoz/makepasswd/)
## Using SSH key (and no password) ## Using SSH key (and no password)
Mount all public keys in the user's `.ssh/keys/` direcotry. All keys are automatically Mount all public keys in the user's `.ssh/keys/` directory. All keys are automatically
appended to `.ssh/authorized_keys`. appended to `.ssh/authorized_keys`.
``` ```

View file

@ -77,14 +77,13 @@ function createUser() {
# Make sure dirs exists and has correct permissions # Make sure dirs exists and has correct permissions
if [ -n "$dir" ]; then if [ -n "$dir" ]; then
while IFS=',' read -ra dirParam; do IFS=',' read -a dirParam <<< $dir
for dirPath in $dirParam; do for dirPath in ${dirParam[@]}; do
dirPath=/home/$user/$dirPath dirPath=/home/$user/$dirPath
echo "Creating and/or setting permissions on $dirPath" echo "Creating and/or setting permissions on $dirPath"
mkdir -p $dirPath mkdir -p $dirPath
chown -R $user:users $dirPath chown -R $user:users $dirPath
done done
done <<< $dir
fi fi
} }

View file

@ -36,7 +36,7 @@ function beforeTest() {
rm -rf "$tmpDir" # clean state rm -rf "$tmpDir" # clean state
mkdir "$tmpDir" mkdir "$tmpDir"
echo "test::$(id -u):$(id -g):dir" >> "$tmpDir/users" echo "test::$(id -u):$(id -g):share,dir1,dir2" >> "$tmpDir/users"
docker run \ docker run \
-v "$tmpDir/users:/etc/sftp-users.conf:ro" \ -v "$tmpDir/users:/etc/sftp-users.conf:ro" \
-v "$scriptDir/id_rsa.pub":/home/test/.ssh/keys/id_rsa.pub:ro \ -v "$scriptDir/id_rsa.pub":/home/test/.ssh/keys/id_rsa.pub:ro \
@ -123,11 +123,16 @@ function testDir() {
runSftpCommands "$sftpContainerName" \ runSftpCommands "$sftpContainerName" \
"test" \ "test" \
"cd dir" \ "cd dir1" \
"mkdir test2" \ "mkdir test-dir1" \
"get -rf test2 $tmpDir/" \ "get -rf test-dir1 $tmpDir/" \
"cd ../dir2" \
"mkdir test-dir2" \
"get -rf test-dir2 $tmpDir/" \
"exit" "exit"
test -d "$tmpDir/test2" test -d "$tmpDir/test-dir1"
assertReturn $? 0
test -d "$tmpDir/test-dir2"
assertReturn $? 0 assertReturn $? 0
} }