mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
disable self connections by default
now that the event manager can create files, self connections may create even more issues than before Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -195,6 +195,7 @@ var (
|
||||
lastLoginMinDelay = 10 * time.Minute
|
||||
usernameRegex = regexp.MustCompile("^[a-zA-Z0-9-_.~]+$")
|
||||
tempPath string
|
||||
allowSelfConnections int
|
||||
fnReloadRules FnReloadRules
|
||||
fnRemoveRule FnRemoveRule
|
||||
fnHandleRuleForProviderEvent FnHandleRuleForProviderEvent
|
||||
@@ -804,6 +805,11 @@ type Provider interface {
|
||||
resetDatabase() error
|
||||
}
|
||||
|
||||
// SetAllowSelfConnections sets the desired behaviour for self connections
|
||||
func SetAllowSelfConnections(value int) {
|
||||
allowSelfConnections = value
|
||||
}
|
||||
|
||||
// SetTempPath sets the path for temporary files
|
||||
func SetTempPath(fsPath string) {
|
||||
tempPath = fsPath
|
||||
|
||||
@@ -497,6 +497,9 @@ func (u *User) GetPermissionsForPath(p string) []string {
|
||||
}
|
||||
|
||||
func (u *User) getForbiddenSFTPSelfUsers(username string) ([]string, error) {
|
||||
if allowSelfConnections == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
sftpUser, err := UserExists(username)
|
||||
if err == nil {
|
||||
err = sftpUser.LoadAndApplyGroupSettings()
|
||||
|
||||
Reference in New Issue
Block a user