I have noticed that if ACLs are applied inside a running container, e.g. setfacl -m g:foo:rwx /var/httpd/conf.d they will persist within the container instance:
But if you stop the instance and publish as an image, then launch a new instance from the image (lxc publish bar --alias=bar; lxc launch bar bar2) if you look at the ACLs on the new container they are not there:
I have some software that sets some ACLs as part of it’s RPM installation %post. As a workaround I am saving a bunch of @reboot root setfacl -m ... cronjobs in /etc/cron.d/fixacls that re-sets the same ACLs.
Is there a more elegant solution that automatically saves and restores ACLs to/from images, or perhaps only runs first boot following a lxd init/launch?
ACLs are stored in xattrs on the filesystem. I think there needs to be some magic which happens to remap the acls when you start up a new image, ie the old “foo” group is not the same as the new “foo” group on the new image.
It seems as though there is a relevant bug report about this in the past, so some features of acls are presumed to be supported: https://github.com/lxc/lxd/issues/4862
However, I wonder if either the publish task forgets to actually save the xattrs (check inside the tarball I guess?) or whether they get stripped and incorrectly adjusted as part of the publish?
I guess you could figure out where the xattr is getting dropped would be a starting point to getting this supported?
I used the lxc export bar bar.tar.gz to create a tarball of a container that had some ACLs set, then re-imported it with lxc import bar.tar.gz bar3 to a different container. The new container bar3 did not contain the ACLs.
If I just restore the tarball directly with tar --xattrs -xf bar.tar.gz the ACLs are not present.
I created a VM named v1 and installed LXD inside that as per your suggestion above. I then executed the test on both side by side in a tmux session. Same issue occurs on both.
The following image is my tmux session. Left is tgapsyd1dbd03, the base LXD host, a Ubuntu Jammy Vmware VM with LXD 5.14 installed via snap. Right is v1 the LXD VM created within tgapsyd1dbd03 as per your prior comment.
Not preserved for me either (lxd 5.14), tested with fresh Ubuntu 22.04.2 LTS servers on two different bare bone machines and mask and other gets lost when export / importing a normal container.