-
Notifications
You must be signed in to change notification settings - Fork 3
Export the fields so they can be be manipulated #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Hi @fabix, |
|
Hello @steiler,
In my use case, I need to inspect existing ACLs and sometimes modify them. It's not possible with the current implementation. Regarding using the same ACLEntry in multiple ACLs, I think that It is the developer's responsibility to know what he's doing. It's just working with pointers. I've added a |
|
If you say you need to chnage them, what does that mean? chnage the Perm on an ACLEntry or what is it exactly you're after? |
|
That means that the user of the program has specified a new acl entry in a |
|
I've released a new version with the acl := &acls.ACL{}
err := acl.Load(filePath, acls.PosixACLAccess)
if err != nil {
log.Errorf("Failed to load ACL: %v", err)
return err
}
newEntry := acls.NewEntry(acls.TAG_ACL_USER, 1000, 6) // user:foo:rw-
if old := acl.GetEntry(newEntry); old != nil {
log.Infof("Entry exists, replacing permissions")
log.Debugf("Before: %s", old.String())
acl.AddEntry(newEntry)
log.Debugf("After: %s", newEntry.String())
} else {
log.Infof("Entry doesn't exist, adding new entry")
acl.AddEntry(newEntry)
}
log.Infof("Applying ACL changes to %s", filePath)
err = acl.Apply(filePath, acls.PosixACLAccess)
if err != nil {
log.Errorf("Failed to apply ACL: %v", err)
return err
}
log.Infof("ACL successfully applied") |
|
Well, I need to compare a list of ACL rules defined in a configuration file with the current state. How can I know whether there are more rules than defined? For example, if a rule |
|
Ok so what you are saying is that you need to get the List of ACLEntries in an ACL to basically sync the definition with the actual configuration. You did not point that out.
Anyways, giving you with |
|
I'd thought about adding this method as well, it could do the stuff if creating an ACL from scratch was possible (problem with |
|
You are right about the version attribute. I'm adding this: // NewACL returns a new ACL instance
func NewACL() *ACL {
return &ACL{
version: 2,
entries: []*ACLEntry{},
}
}You are perfectly right, the perm was not accessable at all. I'm hence also adding getters. // Ensure user has read+execute but not write
newEntry := entry.WithPerm(PermRead | PermExecute).WithoutPerm(PermWrite)
acl.AddEntry(newEntry)This takes the existing AclEntry, adds the Perms (that you can combine via the binary OR) and returns a new AclEntry instance. That you can then add to the ACL, which results in a replace of perms for the tag/id combination. |
|
I think the new methods should be sufficient to do what I need, thanks. |
No description provided.