Documentation
¶
Index ¶
- Constants
- func PermStringToUint(s string) (uint16, error)
- func PermUintToString(p uint16) string
- func Tag2String(i Tag) string
- type ACL
- func (a *ACL) AddEntry(e *ACLEntry) error
- func (a *ACL) Apply(fsPath string, attr ACLAttr) error
- func (a *ACL) DeleteEntry(e *ACLEntry) *ACLEntry
- func (a *ACL) EntryExists(e *ACLEntry) int
- func (a *ACL) Equal(e *ACL) bool
- func (a *ACL) GetEntries() []*ACLEntry
- func (a *ACL) GetEntry(e *ACLEntry) *ACLEntry
- func (a *ACL) Load(fsPath string, attr ACLAttr) error
- func (a *ACL) String() string
- func (a *ACL) ToByteSlice(result *bytes.Buffer)
- type ACLAttr
- type ACLEntry
- func (a *ACLEntry) Equal(e *ACLEntry) bool
- func (e *ACLEntry) HasPerm(perm uint16) bool
- func (e *ACLEntry) ID() uint32
- func (e *ACLEntry) Perm() uint16
- func (a *ACLEntry) String() string
- func (e *ACLEntry) Tag() Tag
- func (a *ACLEntry) ToByteSlice(result *bytes.Buffer)
- func (e *ACLEntry) WithExactPerm(perm uint16) *ACLEntry
- func (e *ACLEntry) WithPerm(perm uint16) *ACLEntry
- func (e *ACLEntry) WithoutPerm(perm uint16) *ACLEntry
- type Tag
Constants ¶
const ( // Undefined ACL type. TAG_ACL_UNDEFINED_FIELD = 0x0 // Discretionary access rights for //processes whose effective user ID //matches the user ID of the file's owner. TAG_ACL_USER_OBJ = 0x1 // Discretionary access rights for // processes whose effective user ID // matches the ACL entry qualifier. TAG_ACL_USER = 0x2 // Discretionary access rights for // processes whose effective groupID or // any supplemental groups match the group // ID of the file's owner. TAG_ACL_GROUP_OBJ = 0x4 // Discretionary access rights for // processes whose effective group ID or // any supplemental groups match the ACL // entry qualifier. TAG_ACL_GROUP = 0x8 // The maximum discretionary access rights // that can be granted to a process in the // file group class. This is only valid // for POSIX.1e ACLs. TAG_ACL_MASK = 0x10 // Discretionary access rights for // processes not covered by any other ACL // entry. This is only valid for POSIX.1e // ACLs. TAG_ACL_OTHER = 0x20 // Same as ACL_OTHER. TAG_ACL_OTHER_OBJ = TAG_ACL_OTHER // Discretionary access rights for all // users. This is only valid for NFSv4 // ACLs. TAG_ACL_EVERYONE = 0x40 )
const ( PermRead uint16 = 0x4 PermWrite uint16 = 0x2 PermExecute uint16 = 0x1 PermAll uint16 = 0x7 PermNone uint16 = 0x0 )
Permission bit constants
Variables ¶
This section is empty.
Functions ¶
func PermStringToUint ¶ added in v0.1.5
PermStringToUint takes a string representation of a permission "rwx" and returns the uint16 representation. an error is returned if the string is not exactly 3 characters long.
func PermUintToString ¶
PermUintToString takes an int representation of a permission and returns the string representation "rwx". not granted permissions appear as "-".
func Tag2String ¶
Types ¶
type ACL ¶
type ACL struct {
// contains filtered or unexported fields
}
ACL handles Posix ACL data
func (*ACL) AddEntry ¶
AddEntry adds the given entry to the ACL It will make sure that no entry with the same Tag and ID combination exists. If so, it will replace (not merge) the existing entry with the given.
func (*ACL) Apply ¶
Apply applies the ACL with its ACLEntries to as either access or default ACLs to the given filesstem path
func (*ACL) DeleteEntry ¶
DeleteEntry deletes the entry that has the same tag and id if it exists and returns the deleted entry
func (*ACL) EntryExists ¶
EntryExists checks if an entry with the given Tag and ID already exist if so it return -1 of not the position of the duplicate is returned as a positive int
func (*ACL) GetEntries ¶ added in v0.1.4
GetEntries returns all ACLEntries of the ACL
func (*ACL) GetEntry ¶ added in v0.1.3
GetEntry returns the entry with the given Tag and ID if it exists, nil otherwise
func (*ACL) Load ¶
Load loads the attr defined POSIX.ACL type (access or default) from the given filepath
func (*ACL) ToByteSlice ¶
ToByteSlice return the ACL in its byte slice representation read to be used by Setxattr(...)
type ACLEntry ¶
type ACLEntry struct {
// contains filtered or unexported fields
}
ACLEntry the ACLEntry represents the single lines of permission.
- tag references the type (group, user, etc.)
- perm is the permission in its numerical format
- id is the id of the group or user or whatever tag points to
func (*ACLEntry) HasPerm ¶ added in v0.1.5
HasPerm checks if the entry has the specified permission bit(s)
func (*ACLEntry) ToByteSlice ¶
ToByteSlice returns the ACLEntry as a byte slice in little endian order, which is the representation required for the Setxattr(...) call
func (*ACLEntry) WithExactPerm ¶ added in v0.1.5
WithExactPerm returns a new ACLEntry with the exact permission specified
func (*ACLEntry) WithPerm ¶ added in v0.1.5
WithPerm returns a new ACLEntry with the specified permission bit(s) added
func (*ACLEntry) WithoutPerm ¶ added in v0.1.5
WithoutPerm returns a new ACLEntry with the specified permission bit(s) removed