How to disable SELINUX for systemd script

selinuxsystemd

I have a systemd script in CentOS 7 which doesn't run properly unless I disable SELINUX. Is it possible to somehow have SELINUX enabled on the system but disable it only for this systemd script?

The systemd script:

[Unit]
Description=Tractor Blade Service
Wants=network.target network-online.target autofs.service
After=network.target network-online.target autofs.service
RequiresMountsFor=/101.102.103.104/pipeline/

[Service]
Type=simple
User=IRUser
ExecStart=/opt/pixar/Tractor-2.1/bin/tractor-blade --debug --log /101.102.103.104/pipeline/logs/tractor/tractor-blade-%H.log --engine=111.222.333.444 --supersede --pidfile=/var/run/tractor-blade.pid

[Install]
WantedBy=multi-user.target

Best Answer

You could run that process as unconfined so it would have the same rights as if SELinux was disabled.

# This will setup the executable to be unconfined. Temporarily
chcon -t unconfined_exec_t /opt/pixar/Tractor-2.1/bin/tractor-blade
# This command will make that permanent
semanage fcontext -a -t unconfined_exec_t /opt/pixar/Tractor-2.1/bin/tractor-blade

You can read more about unconfined processes in Red Hat documentation: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security-Enhanced_Linux/sect-Security-Enhanced_Linux-Targeted_Policy-Unconfined_Processes.html

Related Topic