Error while renaming /etc/selinux/targeted/tmp to /etc/selinux/targeted/active

Hi All,

I am playing with bootc and it appears that when I run semanage more than once in my Containerfile I get the error;

`+ semanage fcontext --add --type container_file_t '/usr/containers(/.*)?'`

`libsemanage.semanage_commit_sandbox: Error while renaming /etc/selinux/targeted/tmp to /etc/selinux/targeted/active. (Directory not empty).`

`libsemanage.semanage_commit_sandbox: Error while renaming /etc/selinux/targeted/previous back to /etc/selinux/targeted/active. (Directory not empty).`

`OSError: Directory not empty` 

Note: In this case the above command is the second in the Containerfile.

The specific command I am running are;

semanage fcontext --add --type httpd_config_t "/usr/httpd(/.*)?"

semanage fcontext --add --type container_file_t "/usr/containers(/.*)?"

I would have expected that anyone using custom paths would need to run this command multiple times so I am suprised I havent found anything using Google.

Appreciate any pointers.

Thanks,

Adam

For anyone else looking for a workaround, I have used the following technique in my containerfile, echoing the commands to file and using semanages option to read command from a file to batch the commands in a single transaction


CUSTOM_SELINUX=/tmp/system-files/selinux.mods

echo fcontext --add --type httpd_config_t "/usr/httpd(/.*)?" >> $CUSTOM_SELINUX

echo fcontext --add --type container_file_t "/usr/containers(/.*)?" >> $CUSTOM_SELINUX

if [[ -f ${CUSTOM_SELINUX} ]]; then
    semanage import --input_file ${CUSTOM_SELINUX}
fi