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: CLOSED EOL
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: 2022-05-25 09:33 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: ---
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-05-25 17:45:29 UTC
Type: Bug
Embargoed:


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

Comment 1 Dimitri Papadopoulos 2021-04-02 09:09:13 UTC
Is this still the case on Fedora 33?

I don't have a Fedora box to test, but perhaps we can find a solution if you can gather some SELinux logs: 
https://wiki.centos.org/HowTos/SELinux#Gathering_Audit_Logs_In_Permissive_Mode

Comment 2 Fedora Program Management 2021-04-29 17:04:44 UTC
This message is a reminder that Fedora 32 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 32 on 2021-05-25.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '32'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 32 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 3 Ben Cotton 2021-05-25 17:45:29 UTC
Fedora 32 changed to end-of-life (EOL) status on 2021-05-25. Fedora 32 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 4 Phil 2022-05-25 09:33:34 UTC
Hi all,

please reopen this bug report. It is not fixed in Fedora 36.

When running in permissive mode openfortivpn works fine, but in enforcing mode the routes cannot be set:

openfortivpn[7536]: WARN:   Could not set route to tunnel gateway (Operation not permitted).

Running in permissive mode the audit log shows absolutely nothing of interest:

type=SERVICE_START msg=audit(1653471054.202:353): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=openfortivpn@foo comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'UID="root" AUID="unset"

I tried:

domain_kernel_load_modules=1
openfortivpn_can_network_connect=1
allow openfortivpn_t self:capability dac_override;

Nothing helped.


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