virsh_selinux(8)

πŸ“¦
version 20250627+git412.dbf877ab7 Β· 7 versions
, in opensuse-leap 16.0

πŸ’… virsh_selinux(8) β€” like, the whole SELinux vibe for virsh processes ✨

okay bestie, welcome to the virsh_selinux(8) page β€” yes that's the manual section 8, and yes this is the SELinux Policy for virsh situation. buckle up πŸŽ€


🌸 NAME 🌸

virsh_selinux β€” Security Enhanced Linux Policy for the virsh processes. that's it, that's the whole name, slay πŸ’…


✨ DESCRIPTION ✨

Security-Enhanced Linux secures the virsh processes via flexible mandatory access control. literally the whole point 🫢

The virsh processes execute with the virsh_t SELinux type. You can check if you've got these processes running by executing the ps command with the -Z qualifier. easy peasy.

For example:

ps -eZ | grep virsh_t

go run it, i'll wait πŸ’–


πŸšͺ ENTRYPOINTS πŸšͺ

The virsh_t SELinux type can be entered via the virsh_exec_t file type. that's the doorway, no cap.

The default entrypoint paths for the virsh_t domain are the following:

/usr/bin/xl, /usr/bin/xm, /usr/bin/virsh

three little icon paths, all iconic πŸ‘‘


🧬 PROCESS TYPES 🧬

SELinux defines process types (domains) for each process running on the system. yes, every process gets its own little domain identity β€” main character energy for real.

You can see the context of a process using the -Z option to ps. (yes, -Z again, it's the moment, let it have it.)

Policy governs the access confined processes have to files. SELinux virsh policy is very flexible, allowing users to setup their virsh processes in as secure a method as possible. tightest access possible, periodt.

The following process types are defined for virsh:

virsh_t, virsh_ssh_t
Note: semanage permissive -a virsh_t can be used to make the process type virsh_t permissive. SELinux does not deny access to permissive process types, but the AVC (SELinux denials) messages are still generated. so like, it stops blocking you but it still talks about you in the logs 😭

πŸ”˜ BOOLEANS πŸ”˜

SELinux policy is customizable based on least access required. virsh policy is extremely flexible and has several booleans that allow you to manipulate the policy and run virsh with the tightest access possible. no wasted permissions here, we're minimalists πŸ’…

If you want to allow all domains to execute in fips_mode, you must turn on the fips_mode boolean. Enabled by default.

setsebool -P fips_mode 1

If you want to allow confined applications to use nscd shared memory, you must turn on the nscd_use_shm boolean. Enabled by default.

setsebool -P nscd_use_shm 1

If you want to support ecryptfs home directories, you must turn on the use_ecryptfs_home_dirs boolean. Disabled by default.

setsebool -P use_ecryptfs_home_dirs 1

If you want to allow confined virtual guests to manage nfs files, you must turn on the virt_use_nfs boolean. Disabled by default.

setsebool -P virt_use_nfs 1

If you want to allow confined virtual guests to manage cifs files, you must turn on the virt_use_samba boolean. Disabled by default.

setsebool -P virt_use_samba 1

five booleans, five setsebool -P commands, we are THRIVING 🌈


πŸ—‚οΈ MANAGED FILES πŸ—‚οΈ

The SELinux process type virsh_t can manage files labeled with the following file types. The paths listed are the default paths for these file types. Heads up bestie: the process's UID still needs to have DAC permissions. SELinux isn't gonna override good old-fashioned file permissions for you, that's not the vibe πŸ™ˆ

cifs_t

(no paths listed, it's just out here living its life)

container_file_t

/var/lib/rkt/cas(/.*)?

nfs_t

(again, no default paths listed, mysterious and gorgeous)

ssh_home_t

/var/lib/[^/]+/.ssh(/.*)?
/root/.ssh(/.*)?
/var/lib/one/.ssh(/.*)?
/srv/gitolite/.ssh(/.*)?
/srv/gitolite3/.ssh(/.*)?
/var/lib/pgsql/.ssh(/.*)?
/var/lib/openshift/[^/]+/.ssh(/.*)?
/var/lib/amanda/.ssh(/.*)?
/var/lib/stickshift/[^/]+/.ssh(/.*)?
/var/lib/nocpulse/.ssh(/.*)?
/var/lib/openshift/gear/[^/]+/.ssh(/.*)?
/root/.shosts
/home/[^/]+/.ssh(/.*)?
/home/[^/]+/.ansible/cp/.*
/home/[^/]+/.shosts

look at all those ssh directories, it's giving ✨infrastructure✨

systemd_passwd_var_run_t

/run/systemd/ask-password(/.*)?
/run/systemd/ask-password-block(/.*)?

vhostmd_tmpfs_t

(no paths, it's shy)

virt_etc_rw_t

/etc/xen/.*/.*
/etc/xen/[^/]*
/etc/libvirt/.*/.*
/etc/libvirt/[^/]*

virt_etc_t

/etc/xen/[^/]*
/etc/libvirt/[^/]*
/etc/xen
/etc/libvirt

virt_image_type

all virtual image files

literally all of them. every single virtual image file. ate. πŸ”₯

virt_lock_t

(no paths listed, but it's important, trust)

virt_lxc_var_run_t

/run/libvirt/lxc(/.*)?
/run/libvirt-sandbox(/.*)?
/run/virtlxcd.pid
/run/libvirt/virtlxcd-sock
/run/libvirt/virtlxcd-sock-ro
/run/libvirt/virtlxcd-admin-sock

xenfs_t

(no paths, just vibes)


🏷️ FILE CONTEXTS 🏷️

SELinux requires files to have an extended attribute to define the file type. yes, files have labels now, we love a rebrand πŸ’–

You can see the context of a file using the -Z option to ls. (-Z is literally the guest star of this entire manpage at this point πŸ‘‘)

Policy governs the access confined processes have to these files. SELinux virsh policy is very flexible, allowing users to setup their virsh processes in as secure a method as possible.

πŸŽ€ STANDARD FILE CONTEXT πŸŽ€

SELinux defines the file context types for the virsh. If you wanted to store files with these types in a different path, you need to execute the semanage command to specify alternate labeling and then use restorecon to put the labels on disk. two-step process, both steps matter, don't skip πŸ™

semanage fcontext -a -t virsh_exec_t '/srv/virsh/content(/.*)?'
restorecon -R -v /srv/myvirsh_content
Note: SELinux often uses regular expressions to specify labels that match multiple files. regex girlies rise πŸ¦‹

The following file types are defined for virsh:

virsh_exec_t

  • Set files with the virsh_exec_t type if you want to transition an executable to the virsh_t domain.

Paths:

/usr/bin/xl, /usr/bin/xm, /usr/bin/virsh

(the same three paths as the entrypoints β€” consistency icon πŸ’…)

Note: File context can be temporarily modified with the chcon command. If you want to permanently change the file context you need to use the semanage fcontext command. This will modify the SELinux labeling database. You will need to use restorecon to apply the labels. so like β€” chcon is the temporary tattoo, semanage fcontext is the real one 😌

πŸ› οΈ COMMANDS πŸ› οΈ

semanage fcontext can also be used to manipulate default file context mappings.

semanage permissive can also be used to manipulate whether or not a process type is permissive.

semanage module can also be used to enable/disable/install/remove policy modules.

semanage boolean can also be used to manipulate the booleans.

system-config-selinux is a GUI tool available to customize SELinux policy settings. for the besties who prefer clicking over typing πŸ–±οΈβœ¨


🫢 AUTHOR 🫢

This manual page was auto-generated using sepolicy manpage. (yes, robot-written, and honestly? it ate.)


πŸ‘€ SEE ALSO πŸ‘€

selinux(8), virsh(8), semanage(8), restorecon(8), chcon(1), sepolicy(8), setsebool(8), virsh_ssh_selinux(8), virsh_ssh_selinux(8)

and yes, virsh_ssh_selinux(8) is listed twice β€” she said it once, she said it again, because she's that important πŸ’€πŸ‘‘


okay that's the whole page, go forth and confine your virsh processes responsibly πŸ§šβ€β™€οΈ

β€” signed, virsh, dated 26-10-06, filed under virsh_selinux(8) πŸ’œ bye bestie!!

πŸ“¦ where this page comes from