mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
file patterns: fix denied except rules
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -981,9 +981,14 @@ func (u *User) getPatternsFilterForPath(virtualPath string) sdk.PatternsFilter {
|
||||
return filter
|
||||
}
|
||||
dirsForPath := util.GetDirsForVirtualPath(virtualPath)
|
||||
for _, dir := range dirsForPath {
|
||||
for idx, dir := range dirsForPath {
|
||||
for _, f := range u.Filters.FilePatterns {
|
||||
if f.Path == dir {
|
||||
if idx > 0 && len(f.AllowedPatterns) > 0 && len(f.DeniedPatterns) > 0 && f.DeniedPatterns[0] == "*" {
|
||||
if f.CheckAllowed(path.Base(dirsForPath[idx-1])) {
|
||||
return filter
|
||||
}
|
||||
}
|
||||
filter = f
|
||||
break
|
||||
}
|
||||
@@ -1004,7 +1009,7 @@ func (u *User) isDirHidden(virtualPath string) bool {
|
||||
return false
|
||||
}
|
||||
filter := u.getPatternsFilterForPath(dirPath)
|
||||
if filter.DenyPolicy == sdk.DenyPolicyHide {
|
||||
if filter.DenyPolicy == sdk.DenyPolicyHide && filter.Path != dirPath {
|
||||
if !filter.CheckAllowed(path.Base(dirPath)) {
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user