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

Test posibility of using chroot in subdirs (#207)

This commit is contained in:
Adrian Dvergsdal 2020-07-14 22:28:13 +02:00
parent c6285fe34c
commit 55900d4327
No known key found for this signature in database
GPG key ID: C1E9E2D9552A42D2

View file

@ -276,6 +276,41 @@ function testWriteAccessToAutocreatedDirs() {
assertTrue "dir with spaces write access" $? assertTrue "dir with spaces write access" $?
} }
function testWriteAccessToLimitedChroot() {
# Modified sshd_config with chrooted home subdir
tmpConfig="$(mktemp)"
sed 's/^ChrootDirectory.*/ChrootDirectory %h\/sftp/' \
< "$testDir/../files/sshd_config" > "$tmpConfig"
# Set correct permissions on chroot
tmpScript="$(mktemp)"
cat > "$tmpScript" <<EOF
mkdir -p /home/*/sftp
chown root:root /home/*/sftp
chmod 755 /home/*/sftp
EOF
chmod +x "$tmpScript"
docker run --name "$containerName" -d \
-v "$sshKeyPub":/home/test/.ssh/keys/id_rsa.pub:ro \
-v "$tmpConfig:/etc/ssh/sshd_config" \
-v "$tmpScript:/etc/sftp.d/limited_home_dir" \
"$imageName" "test::::sftp/upload" \
> "$redirect" 2>&1
waitForServer "$containerName"
assertTrue "waitForServer" $?
runSftpCommands "$containerName" "test" \
"cd upload" \
"mkdir test" \
"exit"
assertTrue "runSftpCommands" $?
docker exec "$containerName" test -d /home/test/sftp/upload/test
assertTrue "limited chroot write access" $?
}
function testBindmountDirScript() { function testBindmountDirScript() {
mkdir -p "$containerTmpDir/custom/bindmount" mkdir -p "$containerTmpDir/custom/bindmount"
echo "mkdir -p /home/custom/bindmount && \ echo "mkdir -p /home/custom/bindmount && \