virtual folders fixes

scp now properly handles virtual folders.

rsync is disabled for users with virtual folders: we execute a system
command and it is not aware about virtual folders.

git is not allowed if the repo path is inside a virtual folder
This commit is contained in:
Nicola Murino
2020-02-24 18:54:35 +01:00
parent 703ccc8d91
commit eb1b869b73
5 changed files with 100 additions and 5 deletions

View File

@@ -799,6 +799,48 @@ func TestSSHCommandQuotaScan(t *testing.T) {
}
}
func TestGitVirtualFolders(t *testing.T) {
permissions := make(map[string][]string)
permissions["/"] = []string{dataprovider.PermAny}
user := dataprovider.User{
Permissions: permissions,
HomeDir: os.TempDir(),
}
fs, _ := user.GetFilesystem("123")
conn := Connection{
User: user,
fs: fs,
}
cmd := sshCommand{
command: "git-receive-pack",
connection: conn,
args: []string{"/vdir"},
}
cmd.connection.User.VirtualFolders = append(cmd.connection.User.VirtualFolders, vfs.VirtualFolder{
VirtualPath: "/vdir",
MappedPath: os.TempDir(),
})
_, err := cmd.getSystemCommand()
if err != errUnsupportedConfig {
t.Errorf("unexpected error: %v", err)
}
cmd.connection.User.VirtualFolders = nil
cmd.connection.User.VirtualFolders = append(cmd.connection.User.VirtualFolders, vfs.VirtualFolder{
VirtualPath: "/vdir",
MappedPath: os.TempDir(),
})
cmd.args = []string{"/vdir/subdir"}
_, err = cmd.getSystemCommand()
if err != errUnsupportedConfig {
t.Errorf("unexpected error: %v", err)
}
cmd.args = []string{"/adir/subdir"}
_, err = cmd.getSystemCommand()
if err != nil {
t.Errorf("unexpected error: %v", err)
}
}
func TestRsyncOptions(t *testing.T) {
permissions := make(map[string][]string)
permissions["/"] = []string{dataprovider.PermAny}
@@ -843,6 +885,14 @@ func TestRsyncOptions(t *testing.T) {
if !utils.IsStringInSlice("--munge-links", cmd.cmd.Args) {
t.Errorf("--munge-links must be added if the user has the create symlinks permission")
}
sshCmd.connection.User.VirtualFolders = append(sshCmd.connection.User.VirtualFolders, vfs.VirtualFolder{
VirtualPath: "/vdir",
MappedPath: os.TempDir(),
})
_, err = sshCmd.getSystemCommand()
if err != errUnsupportedConfig {
t.Errorf("unexpected error: %v", err)
}
}
func TestSystemCommandErrors(t *testing.T) {