Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow systemd's machinectl to clone and/or remove systemd-nspawn/btrfs instances in /var/lib/machines #2143

Open
amessina opened this issue Jun 1, 2024 · 0 comments

Comments

@amessina
Copy link

amessina commented Jun 1, 2024

With a BTRFS filesystem, machinectl can clone a systemd-nspawn container quickly and efficiently.

It also attempts to clone and/or remove any *.nspawn configuration files in /etc/systemd/nspawn or /run/systemd/nspawn, which fails with the current F40 selinux-policy.

The audit2allow rules suggest allowing the systemd_machined_t source context edit access to the etc_t target type. This is not really what we should do.

Requesting that a new type systemd_nspawn_conf_t be created for /etc/systemd/nspwan and /run/systemd/nspawn. Then systemd_machined_t can be allowed to manage those spaces with the appropriate interfaces.

type=AVC msg=audit(1714311930.472:966): avc:  denied  { write } for  pid=27303 comm="(sd-imgclone)" name="nspawn" dev="sda3" ino=64221 scontext=system_u:system_r:systemd_machined_t:s0 tcontext=system_u:object_r:etc_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1714311930.472:967): avc:  denied  { write } for  pid=27303 comm="(sd-imgclone)" path=2F6574632F73797374656D642F6E737061776E2F2332303830363539202864656C6574656429 dev="sda3" ino=2080659 scontext=system_u:system_r:systemd_machined_t:s0 tcontext=system_u:object_r:etc_t:s0 tclass=file permissive=1
type=AVC msg=audit(1714311930.473:968): avc:  denied  { setattr } for  pid=27303 comm="(sd-imgclone)" name="#2080659" dev="sda3" ino=2080659 scontext=system_u:system_r:systemd_machined_t:s0 tcontext=system_u:object_r:etc_t:s0 tclass=file permissive=1
type=AVC msg=audit(1714311930.473:969): avc:  denied  { add_name } for  pid=27303 comm="(sd-imgclone)" name="#2080659" dev="sda3" ino=2080659 scontext=system_u:system_r:systemd_machined_t:s0 tcontext=system_u:object_r:etc_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1714311930.473:970): avc:  denied  { link } for  pid=27303 comm="(sd-imgclone)" name="#2080659" dev="sda3" ino=2080659 scontext=system_u:system_r:systemd_machined_t:s0 tcontext=system_u:object_r:etc_t:s0 tclass=file permissive=1
type=AVC msg=audit(1714317361.800:1372): avc:  denied  { write } for  pid=31798 comm="(sd-imgrm)" name="nspawn" dev="sda3" ino=64221 scontext=system_u:system_r:systemd_machined_t:s0 tcontext=system_u:object_r:etc_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1714317361.800:1373): avc:  denied  { remove_name } for  pid=31798 comm="(sd-imgrm)" name="ehrq.orig.nspawn" dev="sda3" ino=2080659 scontext=system_u:system_r:systemd_machined_t:s0 tcontext=system_u:object_r:etc_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1714317361.800:1374): avc:  denied  { unlink } for  pid=31798 comm="(sd-imgrm)" name="ehrq.orig.nspawn" dev="sda3" ino=2080659 scontext=system_u:system_r:systemd_machined_t:s0 tcontext=system_u:object_r:etc_t:s0 tclass=file permissive=1
#============= systemd_machined_t ==============
allow systemd_machined_t etc_t:dir { add_name remove_name write };
allow systemd_machined_t etc_t:file { link setattr unlink write };
allow systemd_machined_t systemd_nspawn_var_run_t:dir { add_name remove_name write };
allow systemd_machined_t systemd_nspawn_var_run_t:file { create getattr lock open read unlink write };
@amessina amessina changed the title Allow systemd's machinectl to clone and/or remove systemd-nspawn/brfs instances in /var/lib/machines Allow systemd's machinectl to clone and/or remove systemd-nspawn/btrfs instances in /var/lib/machines Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant