From 6f719bc3c19d56279d2d76d3bcf8fb66ace2d2fb Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 2 Sep 2025 04:54:34 +0900 Subject: system: update doc commands and remove mutex The mutex is not really doing anything, none of these methods make sense when called concurrently anyway. The copylocks analysis is still satisfied by the noCopy struct. Signed-off-by: Ophestra --- system/acl.go | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'system/acl.go') diff --git a/system/acl.go b/system/acl.go index 82777b95..04320563 100644 --- a/system/acl.go +++ b/system/acl.go @@ -9,37 +9,33 @@ import ( "hakurei.app/system/acl" ) -// UpdatePerm appends an ephemeral acl update Op. +// UpdatePerm appends [ACLUpdateOp] to [I] with the [Process] criteria. func (sys *I) UpdatePerm(path string, perms ...acl.Perm) *I { sys.UpdatePermType(Process, path, perms...) - return sys } -// UpdatePermType appends an acl update Op. +// UpdatePermType appends [ACLUpdateOp] to [I]. func (sys *I) UpdatePermType(et Enablement, path string, perms ...acl.Perm) *I { - sys.lock.Lock() - defer sys.lock.Unlock() - - sys.ops = append(sys.ops, &ACL{et, path, perms}) - + sys.ops = append(sys.ops, &ACLUpdateOp{et, path, perms}) return sys } -type ACL struct { +// ACLUpdateOp maintains [acl.Perms] on a file until its [Enablement] is no longer satisfied. +type ACLUpdateOp struct { et Enablement path string perms acl.Perms } -func (a *ACL) Type() Enablement { return a.et } +func (a *ACLUpdateOp) Type() Enablement { return a.et } -func (a *ACL) apply(sys *I) error { +func (a *ACLUpdateOp) apply(sys *I) error { msg.Verbose("applying ACL", a) return newOpError("acl", acl.Update(a.path, sys.uid, a.perms...), false) } -func (a *ACL) revert(sys *I, ec *Criteria) error { +func (a *ACLUpdateOp) revert(sys *I, ec *Criteria) error { if ec.hasType(a) { msg.Verbose("stripping ACL", a) err := acl.Update(a.path, sys.uid) @@ -55,17 +51,17 @@ func (a *ACL) revert(sys *I, ec *Criteria) error { } } -func (a *ACL) Is(o Op) bool { - a0, ok := o.(*ACL) - return ok && a0 != nil && - a.et == a0.et && - a.path == a0.path && - slices.Equal(a.perms, a0.perms) +func (a *ACLUpdateOp) Is(o Op) bool { + target, ok := o.(*ACLUpdateOp) + return ok && a != nil && target != nil && + a.et == target.et && + a.path == target.path && + slices.Equal(a.perms, target.perms) } -func (a *ACL) Path() string { return a.path } +func (a *ACLUpdateOp) Path() string { return a.path } -func (a *ACL) String() string { +func (a *ACLUpdateOp) String() string { return fmt.Sprintf("%s type: %s path: %q", a.perms, TypeString(a.et), a.path) } -- cgit v1.3.1