fix: align CHFS directory rule inheritance

This commit is contained in:
OpenClaw Agent
2026-09-21 18:37:41 +08:00
parent 5022826948
commit 6c28bfecc9
4 changed files with 44 additions and 9 deletions
+13 -1
View File
@@ -89,6 +89,18 @@ func (m *Manager) Authenticate(user, pwd string) *Account {
return nil
}
func (a *Account) MaskFor(path string) PermMask {
return a.maskFor(path, false)
}
// MaskForEntry returns the permission shown for a directory/file while its
// parent directory is being listed. CHFS section rules rule.r/rule.w/rule.d
// affect the contents of the named directory, but the directory entry itself
// keeps the inherited permission until it is opened.
func (a *Account) MaskForEntry(path string) PermMask {
return a.maskFor(path, true)
}
func (a *Account) maskFor(path string, entry bool) PermMask {
path = strings.Trim(path, "/")
best := -1
mask := a.Mask
@@ -97,7 +109,7 @@ func (a *Account) MaskFor(path string) PermMask {
if !matchPath(d, path) {
continue
}
if r.ChildrenOnly && matchPathExact(d, path) {
if entry && r.ChildrenOnly && matchPathExact(d, path) {
continue
}
if len(d) > best {