In my cf-serverd's promises.cf I have a bundle like
bundle server host_rules(key, host) {
access:
"/srv/cfengine3/$(host)"
admit_keys => { "$(key)" };
}
I tried to instanciate it with
body common control {
bundlesequence =>
{
generic_rules,
host_rules("MD5=362c5fcf568b492f78ae392229299c05", "foo.example.com"),
};
}
But (with cfengine-3.8.1) this does not seem to have an effect. E.g. cf-serverd -v reports only the access rules in the generic_rules bundle and an access to foo.example.com's files is refused.
generic_rules (which is a simple bundle server generic_rules { ... } bundle) seems to be evaluated when not listed the common bundlesequence.
How can I expand the host_rules bundle in the cf-serverd setup?
EDIT:
I intent to give access to some directories only to a corresponding host which is identified by its key. I know that it is possible to use $(connection.key) in the pathname but dislike it because
it is unreadable (having dozens of directories with meaningless
MD5=...names makes it difficulty to find the directory belonging to 'foo.example.com')it creates trouble when client key changes (e.g. because it was compromised or because host will be reinstalled). 'git' (which is used to organize my cfengine rules) does not support renaming of files/directories and I would lose history of changes with 'git mv'.
For reference: https://groups.google.com/forum/#!topic/help-cfengine/ba5i_1UXPrU
The connection variables are expanded by
cf-serverdwhen clients connect. In the case ofconnection.hostname, the variable expands to the hostname of the connecting agent as determined by a reverse DNS lookup from cf-serverd. So you need to make sure that you have proper reverse dns resolution in order to use that. If instead of organizing the files by hostname, you organized them by key sha you should be able to allow each host access to its own directory using something like the following:And then in an agent bundle you can do this:
Now you can have a directory for each host in
/srv/cfengine3/named for the public key sha of the host. Each host is only allowed to access its own directory since you have mapped the directory to the admit_keys in a 1:1 relationship.