I have a server with some OpenVPN instances (one server, several clients) running on Debian with enforcing SELinux. The connections to some of the VPN servers my machine is connecting to are somewhat unstable, and the OpenVPN instances on my machine crash now and then, so I had set up a cronjob to restart them in case of a crash.
Now the problem is, that this cronjob fails due to issues with SELinux, which I don't really understand. Restarting any OpenVPN instance by hand from commandline, using the same command, works fine. This ist what audit says:
type=AVC msg=audit(1422960005.730:3567927): avc: denied { sys_module } for pid=14309 comm="ifconfig" capability=16 scontext=system_u:system_r:openvpn_t:s0 tcontext=system_u:system_r:openvpn_t:s0 tclass=capability Was caused by: Missing type enforcement (TE) allow rule. You can use audit2allow to generate a loadable module to allow this access. type=AVC msg=audit(1422960005.722:3567921): avc: denied { relabelfrom } for pid=14295 comm="openvpn" scontext=system_u:system_r:openvpn_t:s0 tcontext=unconfined_u:system_r:openvpn_t:s0-s0:c0.c1023 tclass=tun_socket Was caused by: #Constraint rule: constrain tun_socket { create relabelfrom relabelto } ((u1 == u2 -Fail-) or (t1 == { logrotate_t ldconfig_t initrc_t sysadm_t dpkg_t lvm_t mdadm_t unconfined_mount_t dpkg_script_t newrole_t local_login_t sysadm_passwd_t system_cronjob_t tmpreaper_t unconfined_execmem_t httpd_unconfined_script_t groupadd_t depmod_t insmod_t kernel_t passwd_t updpwd_t apmd_t apt_t chfn_t init_t sshd_t udev_t remote_login_t inetd_child_t restorecond_t setfiles_t unconfined_t systemd_tmpfiles_t sulogin_t useradd_t } -Fail-) ); Constraint DENIED # Possible cause is the source user (system_u) and target user (unconfined_u) are different. # Possible cause is the source level (s0) and target level (s0-s0:c0.c1023) are different. I had already set up a local openvpn configuration for SELinux, in order to get it running at all. It looks like this:
module openvpn_local 1.0; require { type openvpn_t; type kernel_t; type udev_t; type var_run_t; class system module_request; class file { read append }; class capability sys_module; class tun_socket { relabelfrom relabelto }; } #============= openvpn_t ============== allow openvpn_t kernel_t:system module_request; # allow openvpn_t self:capability sys_module; allow openvpn_t self:tun_socket { relabelfrom relabelto }; allow udev_t var_run_t:file { read append }; This setup had worked, before I had to make some changes on my setup, to run the OpenVPN instances on static devices nodes. Since then, the granted rights don't seem to be sufficient anymore.
Any help, to set up a fine grained solution for this, or how to improve the local SELinux module for OpenVPN would be greatly appreciated!