pop-os / cosmic-epoch

Next generation Cosmic desktop environment
1.74k stars 55 forks source link

Proper SELinux labeling #132

Open skewballfox opened 10 months ago

skewballfox commented 10 months ago

Hey, recently had to figure out how to do this for creating a custom wayland session(just a script and a desktop file). I thought it might be useful to document a few things that will be necessary for using cosmic without disabling selinux.

the desktop file under wayland sessions needs to have the label system_u:object_r:usr_t:s0, this can be set permanently with

sudo semanage fcontext -a -s system_u -t usr_t /usr/share/wayland-sessions/cosmic.desktop
#then to apply it immediately
sudo restorecon /usr/share/wayland-sessions/cosmic.desktop

note the -a flag might result in an error if the file(s) are already labeled.

I'm not sure what the required label is for the systemd-sysext, but I imagine that since it's sort of an overlay, it should have the same label as the directory it's overlaying. you can copy the label from another file or directory in selinux like this:

semanage fcontext -a -e /home/Ben '/websites(/.*)?' 
restorecon -vvRF /websites

a useful check when figuring out the label for a directory or file would be the -Z flag for ls which will adds selinux info to the normal output.

you can also just set it to selinux to permissive and monitor the logs

journalctl -t setroubleshoot --since= [time]