From d961e18d7320f856618ef4f90d4104d939e072ac Mon Sep 17 00:00:00 2001 From: Adrian Dvergsdal Date: Fri, 12 Aug 2016 20:45:21 +0200 Subject: [PATCH] Fix dir for loop --- README.md | 2 +- entrypoint | 15 +++++++-------- tests/run | 15 ++++++++++----- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 7ee89c2..b4b93de 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ Tip: you can use [atmoz/makepasswd](https://hub.docker.com/r/atmoz/makepasswd/) ## 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`. ``` diff --git a/entrypoint b/entrypoint index 18d9e7b..6ddd780 100755 --- a/entrypoint +++ b/entrypoint @@ -77,14 +77,13 @@ function createUser() { # Make sure dirs exists and has correct permissions if [ -n "$dir" ]; then - while IFS=',' read -ra dirParam; do - for dirPath in $dirParam; do - dirPath=/home/$user/$dirPath - echo "Creating and/or setting permissions on $dirPath" - mkdir -p $dirPath - chown -R $user:users $dirPath - done - done <<< $dir + IFS=',' read -a dirParam <<< $dir + for dirPath in ${dirParam[@]}; do + dirPath=/home/$user/$dirPath + echo "Creating and/or setting permissions on $dirPath" + mkdir -p $dirPath + chown -R $user:users $dirPath + done fi } diff --git a/tests/run b/tests/run index 246fec8..6baeed1 100755 --- a/tests/run +++ b/tests/run @@ -36,7 +36,7 @@ function beforeTest() { rm -rf "$tmpDir" # clean state mkdir "$tmpDir" - echo "test::$(id -u):$(id -g):dir" >> "$tmpDir/users" + echo "test::$(id -u):$(id -g):share,dir1,dir2" >> "$tmpDir/users" docker run \ -v "$tmpDir/users:/etc/sftp-users.conf:ro" \ -v "$scriptDir/id_rsa.pub":/home/test/.ssh/keys/id_rsa.pub:ro \ @@ -123,11 +123,16 @@ function testDir() { runSftpCommands "$sftpContainerName" \ "test" \ - "cd dir" \ - "mkdir test2" \ - "get -rf test2 $tmpDir/" \ + "cd dir1" \ + "mkdir test-dir1" \ + "get -rf test-dir1 $tmpDir/" \ + "cd ../dir2" \ + "mkdir test-dir2" \ + "get -rf test-dir2 $tmpDir/" \ "exit" - test -d "$tmpDir/test2" + test -d "$tmpDir/test-dir1" + assertReturn $? 0 + test -d "$tmpDir/test-dir2" assertReturn $? 0 }