0
0
Fork 0
mirror of https://github.com/atmoz/sftp.git synced 2024-12-08 13:05:39 -05:00

Merge branch 'master' into alpine

This commit is contained in:
Adrian Dvergsdal 2016-08-12 20:45:38 +02:00
commit 2f53c77da6
3 changed files with 20 additions and 16 deletions

View file

@ -15,9 +15,9 @@ This is an automated build linked with the [debian](https://hub.docker.com/_/deb
- Set UID/GID manually for your users if you want them to make changes to - Set UID/GID manually for your users if you want them to make changes to
your mounted volumes with permissions matching your host filesystem. your mounted volumes with permissions matching your host filesystem.
- Add directory names at the end, if you want to create them and/or set user - Add directory names at the end, if you want to create them and/or set user
owership. Perfect when you just want a fast way to upload something without ownership. Perfect when you just want a fast way to upload something without
mounting any directories, or you want to make sure a directory is owned by mounting any directories, or you want to make sure a directory is owned by
a user. a user (chown -R).
- Mount volumes in user's home direcotry. - Mount volumes in user's home direcotry.
- The users are chrooted to their home directory, so you must mount the - The users are chrooted to their home directory, so you must mount the
volumes in separate directories inside the user's home directory volumes in separate directories inside the user's home directory
@ -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
} }