system/acl: do not fail gone revert target
A removed file effectively already has its ACLs stripped, so failing this makes no sense. Still print a message to warn about it. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
65094b63cd
commit
1818dc3a4c
@ -1,7 +1,9 @@
|
|||||||
package system
|
package system
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
"git.gensokyo.uk/security/fortify/acl"
|
"git.gensokyo.uk/security/fortify/acl"
|
||||||
@ -41,7 +43,13 @@ func (a *ACL) apply(sys *I) error {
|
|||||||
func (a *ACL) revert(sys *I, ec *Criteria) error {
|
func (a *ACL) revert(sys *I, ec *Criteria) error {
|
||||||
if ec.hasType(a) {
|
if ec.hasType(a) {
|
||||||
sys.println("stripping ACL", a)
|
sys.println("stripping ACL", a)
|
||||||
return sys.wrapErrSuffix(acl.Update(a.path, sys.uid),
|
err := acl.Update(a.path, sys.uid)
|
||||||
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
|
// the ACL is effectively stripped if the file no longer exists
|
||||||
|
sys.printf("target of ACL %s no longer exists", a)
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
return sys.wrapErrSuffix(err,
|
||||||
fmt.Sprintf("cannot strip ACL entry from %q:", a.path))
|
fmt.Sprintf("cannot strip ACL entry from %q:", a.path))
|
||||||
} else {
|
} else {
|
||||||
sys.println("skipping ACL", a)
|
sys.println("skipping ACL", a)
|
||||||
|
Loading…
Reference in New Issue
Block a user