countermode wrote:I wondered myself whether dynamic parameter expansion like %u for username and so on would be a nice and useful feature.
They would be, but I can see a whole lot of problems trying to implement it. Now, using something
%uid would be pretty easy to implement (but require sysadmins to change system structure to be useful -- for example put homedirs in /home/%UID), but
%username is much more problematic. Kernel does not know about usernames, it only handles UIDs, so every time file is accessed you would have to parse /etc/passwd to find the username (which would be not only horribly inefficient, but also problematic from kernelspace/userspace separation point). More efficient alternative would be to track /etc/passwd in realtime, and reload cache of it every time it changes. But that would only solve (partly) the performance problem. Requiring user to reload policy manually every time they change /etc/passwd would work OK, but would annoy sysadmins greatly (and as you point below, can be implemented today if you wish with your faveourite text preprocessor)
Also, there is a problem that there could well be several different usernames with same UID - although not usual, it is allowed, and kernel would be unable to map UID to username uniquely (which spawns whole another set of problems - would you use only first one? last one? or all of them, creating several sub-rules? )
But anyway, you can always use M4 or something like that to auto-generate policies from templates.
Sure. There is also
include directive in grsec itself which might help to keep it less cubersome for static parts of policy. But on systems with bigger number of users (where is grsec RBAC policy probably most needed) the policy would grow to quite some size, take an age to (re-)load, and eat many resources.
On the other side, grsec implementing
%uid would only have one copy of policy regardless of the number of users on the system, thus being quite efficient. But sysadmins would have to change from /home/%username to /home/%uid format (perhaps keeping /home/%username -> /home/%uid symlink for compatibility). And it would not cover all cases (like allowing access to /tmp/gpg-%username etc. - but perhaps DAC is good enough for those peripheral cases; or one could set TMPDIR to /home/%uid/tmp or such and the use RBAC MAC rules to rule them along with other stuff belonging to that %uid)