api.c: Adding support for loading configuration files from cgrules.d directory
Implementation of loading rules from /etc/cgrules.d/. Explanation is in the
cover letter. New function cgroup_parse_rules_file created,
calling cgroup_parse_rules. cgroup_parse_rules is invoked only in
cgroup_change_cgroup_flags, cgroup_init_rules_cache and
cgroup_reload_cached_rules functions. For them the change in cgroup_parse_rules
implementation is transpart.
Tested with two configuration files in /etc/cgrules.d/ and all rules
in /etc/cgrules.conf commented out:
$ cat /etc/cgrules.conf
#*:ls cpu strom/%u
#*:sleep memory les/%g
$ cat /etc/cgrules.d/cgrules1.conf
*:ls cpu strom/%u
Tested to cache reload as well by sending SIGUSR2 signal to running
cgrulesengd process. After first reload I commented out all rules => no
rules match after invoking ls command. After second reload I uncommented
out ls rule => rule match after invoking ls command. After third reload
I uncommented out ls and sleep rule => debug output of cgrulesengd shows
both rules loaded in the cache
Changelog:
* CGROUP_PARSE_STATE_UNLOCK removed
* reformulation of comment to "Cannot read directory. However,
CGRULES_CONF_FILE is succesfully parsed. Thus return as a success for
back compatibility."
* errno = 0 removed, once it is not zero, function returns, so need to set
it to 0 in every iteration
* fprintf replaced by cgroup_err
* added missing unlocks + new label unlock_list for all returns
This
- * finds a rule matching the given UID or GID. It will store this rule in rl,
+ * finds a rule matching the given UID or GID. It will store this rule in trl,
is valid correction. "It will store this rule in rl" talks about cache being
disabled. In this case, it is stored into trl.
Signed-off-by: Jan Chaloupka <jchaloup@redhat.com> Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>