From 55900d43277a83e5a2d61b0ec4af3233f4131258 Mon Sep 17 00:00:00 2001 From: Adrian Dvergsdal Date: Tue, 14 Jul 2020 22:28:13 +0200 Subject: [PATCH] Test posibility of using chroot in subdirs (#207) --- tests/run | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/run b/tests/run index dce27bd..b05c449 100755 --- a/tests/run +++ b/tests/run @@ -276,6 +276,41 @@ function testWriteAccessToAutocreatedDirs() { 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" < "$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() { mkdir -p "$containerTmpDir/custom/bindmount" echo "mkdir -p /home/custom/bindmount && \