I have a python script, running as a systemd unit, that I need to run in the httpd_t SELinux context under the nginx user, I have tried using runcon but it says that the transition is not allowed and if I allow the transition using audit2allow it then denies the python3 entry point and I am not willing to give httpd_t access to bin_t. Is there any way to do this?
2
Answers
I ended up just writing a custom policy that allows
unconfined_service_t
to transition tohttpd_t
and using a shebang indicating the the script was a python script to not need to specify/usr/bin/python3
in theExecStart
command thus eliminating mybin_t
issues.init_t
can executehttpd_exec_t
, andhttpd_exec_t
can transition tohttpd_t
.So you should be able to do what you want with:
You might need some booleans too, you’ll see if it is needed with
audit2allow -a
.ref. 1, 2, 3