Skip to content

cgroups: Fix permissions on mocked CGroup files

Patrick Steinhardt requested to merge pks-cgroups-fix-mock-permissions into master

Some of the CGroup tests set up their own mock CGroup hierarchy such that we can test things without requiring "real" CGroups. The setup we have is lacking though: first we create control files which belong to the "memory" controller for the "cpu" controller, as well. Second we fail to setup CPU-controller related files. And third, we don't set up files for the CGroup shards. The result is that if these files get created by the cgroups package, then they will have their permission bits set to all-zeroes.

This seems to work on some machines, most importantly in our CI. The most likely explanation why it works is that CI tests run as the "root" user, which has the DAC_OVERRIDE capability and may thus read files which have no read permissions. It does cause failure on my own machine though, where I have a "sane" environment which properly respects Unix permission bits.

Fix all of these issues by refactoring the way we set up the mocks. First, we only write control files associated with each of the controllers we use. Second, we start to write files which are expected for the CPU controller. And finally, we also mock the shards.

Merge request reports

Loading