I’m trying to run a GUI application inside a rootless podman container.
There are many instructions for how to do this, but most require running as root, using docker, neither of which is a viable option for me. I’m running x11 instead of wayland (not just sure why that is, but that’s for another day) and I’d like to make the combination as reasonably secure as possible.
Here’s what I have so far that seems to have come closest:
podman run -it --rm -v $XAUTHORITY:$XAUTHORITY:ro -v /tmp/.X11-unix:/tmp/.X11-unix:Z --userns keep-id -e "DISPLAY" x11test:latest xeyes
This does not result in an SELINUX exception and there is no error in the logs, but it fails with the message:
Error: lsetxattr /tmp/.X11-unix: operation not permitted
If I instead change the permissions on the /tmp/.X11-unix
directory to read only, like this:
podman run -it --rm -v $XAUTHORITY:$XAUTHORITY:ro -v /tmp/.X11-unix:/tmp/.X11-unix:ro --userns keep-id -e "DISPLAY" x11test:latest xeyes
I do get a SELINUX exception and it advises me in the report that if I want to allow xeyes
access to the X1 sock file, I should execute:
ausearch -c 'xeyes' --raw | audit2allow -M my-xeyes
semodule -X 300 -i my-xeyes.pp
However, that doesn’t work either. Trying the first line (as root) gives me this error:
compilation failed:
my-xeyes.te:16:ERROR 'syntax error' at token 'mlsconstrain' on line 16:
mlsconstrain sock_file { write setattr } ((h1 dom h2 -Fail-) or (t1 != mcs_constrained_type -Fail-) ); Constraint DENIED
# mlsconstrain sock_file { ioctl read getattr } ((h1 dom h2 -Fail-) or (t1 != mcs_constrained_type -Fail-) ); Constraint DENIED
/usr/bin/checkmodule: error(s) encountered while parsing configuration
Can someone advise how I can do this without blowing a big hole in my security?