mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
sftpd: add support for chmod/chown
added matching permissions too and a new setting "setstat_mode". Setting setstat_mode to 1 you can keep the previous behaviour that silently ignore setstat requests
This commit is contained in:
@@ -191,11 +191,39 @@ func TestSFTPCmdTargetPath(t *testing.T) {
|
||||
User: u,
|
||||
}
|
||||
_, err := connection.getSFTPCmdTargetPath("invalid_path")
|
||||
if err != sftp.ErrSSHFxOpUnsupported {
|
||||
if err != sftp.ErrSSHFxNoSuchFile {
|
||||
t.Errorf("getSFTPCmdTargetPath must fal with the expected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSFTPErrorFromOSError(t *testing.T) {
|
||||
err := os.ErrNotExist
|
||||
err = getSFTPErrorFromOSError(err)
|
||||
if err != sftp.ErrSSHFxNoSuchFile {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
err = os.ErrPermission
|
||||
err = getSFTPErrorFromOSError(err)
|
||||
if err != sftp.ErrSSHFxPermissionDenied {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
err = getSFTPErrorFromOSError(nil)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetstatModeIgnore(t *testing.T) {
|
||||
originalMode := setstatMode
|
||||
setstatMode = 1
|
||||
connection := Connection{}
|
||||
err := connection.handleSFTPSetstat("invalid", nil)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v setstat should be silently ignore in mode 1", err)
|
||||
}
|
||||
setstatMode = originalMode
|
||||
}
|
||||
|
||||
func TestSFTPGetUsedQuota(t *testing.T) {
|
||||
u := dataprovider.User{}
|
||||
u.HomeDir = "home_rel_path"
|
||||
|
||||
Reference in New Issue
Block a user