Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ch ¶
type Ch struct {
// contains filtered or unexported fields
}
Ch is used to chmod and chown files such that they match their desired group.
func New ¶
func New(rs *RulesStore, logger log15.Logger) *Ch
New returns a Ch what will use your RulesStore to see what work needs to be done on the paths this Ch will receive when Do() is called on it.
Changes made will be logged to the given logger.
func (*Ch) Do ¶
Do is a github.com/wtsi-ssg/wrstat/stat Operation that passes path to our PathCheck callback, and if it returns true, does the following chmod and chown-type behaviours, making use of the supplied Lstat info to avoid doing unnecessary repeated work:
1. Ensures that the GID of the path is the returned GID. 2. If path is a directory, ensures it has setgid applied (group sticky). 3. Ensures that User execute permission is set if group execute was set. 4. Ensures that group permissions match user permissions. 5. Forces user and group read and writeability.
Any errors are returned without logging them, except for "not exists" errors which are silently ignored since these are expected.
Any changes we do on disk are logged to our logger.
type Rule ¶
type Rule struct {
// contains filtered or unexported fields
}
Rule describes desired file and directory permissions and ownership.
func (*Rule) DesiredDirPerms ¶
DesiredDirPerms returns the desired dir permissions as modified by the given current permissions.
func (*Rule) DesiredFilePerms ¶
DesiredFilePerms returns the desired file permissions as modified by the given current permissions.
func (*Rule) DesiredGroup ¶
DesiredGroup returns the desired group id if one was set, otherwise returns the given gid.
func (*Rule) DesiredUser ¶
DesiredUser returns the desired user id if one was set, otherwise returns the given uid.
type RulesStore ¶
type RulesStore struct {
// contains filtered or unexported fields
}
RulesStore holds permission and ownership changing rules for directories that can be retrieved by file path.
func NewRulesStore ¶
func NewRulesStore() *RulesStore
NewRulesStore returns a new RulesStore. It can be chained with FromTSV().
func (*RulesStore) FromTSV ¶
func (r *RulesStore) FromTSV(tsvReader *TSVReader) (*RulesStore, error)
FromTSV returns a RulesStore with rules taken from a ch.tsv via a TSVReader.
func (*RulesStore) Get ¶
func (r *RulesStore) Get(path string) *Rule
Get returns the Rule for the longest directory containing the given path. Returns nil if no parent directory of the path is in the store.
type TSVReader ¶
type TSVReader struct {
// contains filtered or unexported fields
}
TSVReader is for parsing the custom ch.tsv file format, which has tab separated columns:
directory user group fileperms dirperms
*perms format is rwxrwxrwx for user,group,other, where - means remove the permission, * means leave it unchanged, and one of [rwx] means set it. s for the group x would enable setting group sticky bit. s implies x. Using ^ in at least 2 equivalent places to mean "set all if any set". ie. '**^**^***` would mean "change nothing, except if execute is set on user or group, set it on both".
user and group can be unix username or unix group name. * means don't set it. Use ^ to mean copy from the directory.
The file can have blank lines and comment lines that begin with #, which will be ignored.
func NewTSVReader ¶
NewTSVReader returns a new TSVReader which can read ch.tsv files.