Bug 1858358 - Selinux prevents openfortivpn service from creating routes and no AVC
Summary: Selinux prevents openfortivpn service from creating routes and no AVC
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: openfortivpn
Version: 32
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Lubomir Rintel
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-07-17 16:32 UTC by Mike Schmidt
Modified: 2020-07-17 16:32 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: ---
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug


Attachments (Terms of Use)

Description Mike Schmidt 2020-07-17 16:32:24 UTC
Description of problem:

Environment: Fedora32 uptodate with selinux (selinux-policy v3.14.5-42) enforcing

Running openfortivpn manually via sudo works perfectly. All routes are created:

[mike@... ~]$ sudo openfortivpn -c /etc/openfortivpn/kelowna.conf &
INFO:   Connected to gateway.
INFO:   Authenticated.
INFO:   Remote gateway has allocated a VPN.
Using interface ppp0
Connect: ppp0 <--> /dev/pts/11
....

[mike@... ~]$ ip route
default via 10.9.8.2 dev wlp3s0 proto dhcp metric 600 
10.0.0.0/24 dev ppp0 scope link 
10.1.0.0/24 dev ppp0 scope link 
10.5.0.0/24 dev ppp0 scope link 
10.9.8.0/24 dev wlp3s0 proto kernel scope link src 10.9.8.235 metric 600 
....

However, when running as a service, no routes are created:

[mike@... ~]$ ip route
default via 10.9.8.2 dev wlp3s0 proto dhcp metric 600 
10.9.8.0/24 dev wlp3s0 proto kernel scope link src 10.9.8.235 metric 600 


[mike@... ~]$ journalctl -u openfortivpn@kelowna
...
Jul 13 19:04:24 sv-schmidt openfortivpn[39791]: INFO:   Interface ppp0 is UP.
Jul 13 19:04:24 sv-schmidt openfortivpn[39791]: INFO:   Setting new routes...
Jul 13 19:04:24 sv-schmidt openfortivpn[39791]: WARN:   Could not set route to vpn server (Operation not permitted).
Jul 13 19:04:24 sv-schmidt openfortivpn[39791]: WARN:   Could not set route to tunnel gateway (Operation not permitted).
Jul 13 19:04:24 sv-schmidt openfortivpn[39791]: WARN:   Could not set route to tunnel gateway (Operation not permitted).
Jul 13 19:04:24 sv-schmidt openfortivpn[39791]: WARN:   Could not set route to tunnel gateway (Operation not permitted).
Jul 13 19:04:24 sv-schmidt openfortivpn[39791]: INFO:   Adding VPN nameservers...
Jul 13 19:04:24 sv-schmidt openfortivpn[39791]: INFO:   Tunnel is up and running.
...


Note that NO AVC was created in the audit log. 


If, on the other hand, I set selinux to permissive, there is no problem. Since there is no AVC, there is no way to know how to fix it. 

I also tried setting "User=root" in the systemd service unit, nothing changed.

Version-Release number of selected component (if applicable): 1.14.1


How reproducible:
Always

Steps to Reproduce:
1. Have selinx enforcing
2. Run openfortivpn manually to confirm all routes are created
3. set selinux to permissive
4. start the service, all routes are created
5. set selinux back to enforcing
6. start the service again(as provided by the rpm), no routes are created 
4. Check for AVCs


Actual results:
No routes are created by the VPN

Expected results:
routes are creatred by the vpn

Additional info:

It is also unable to delete the routes (made when it was run manually or permissive)

The sebool for openfortivpn is set to on: 

[mike@... ~]$ getsebool -a | grep openfortivpn
openfortivpn_can_network_connect --> on

service unit: 

[mike@... ~]$ cat /usr/lib/systemd/system/openfortivpn@.service
[Unit]
Description=OpenFortiVPN for %I
After=network-online.target
Documentation=man:openfortivpn(1)

[Service]
Type=simple
PrivateTmp=true
ExecStart=/usr/bin/openfortivpn -c /etc/openfortivpn/%I.conf
OOMScoreAdjust=-100

[Install]
WantedBy=multi-user.target


Note You need to log in before you can comment on or make changes to this bug.