pia-foss / desktop

Private Internet Access - Desktop VPN Client for Windows/macOS/Linux
Other
263 stars 50 forks source link

The app does not recognize NetworkManager status with OpenRC correctly #27

Closed vsvjoirwv closed 3 years ago

vsvjoirwv commented 3 years ago

Hi,

First I want to thank you for the wonderful job you do, the app is really good. There is an issue with the app that I've encountered.

App version: 2.8.1 System: Gentoo with OpenRC and NetworkManager.

Relevant info

In OpenRC in Gentoo the NetworkManager service status works in the following way (quote from a changelog): "Change the NetworkManager OpenRC service to provide net; the service's status is set to 'inactive' when NetworkManager is running but has no connections up, and to 'started' when NetworkManager is connected"

How to reproduce Just take Gentoo with OpenRC and NetworkManager and install the PIA app and set it to launch on system startup.

Description

When the computer starts, the NetworkManager service starts in the default runlevel. It shows at first 'inactive' status (this means that NetworkManager has started and has not established any connection yet, this is totally normal). After NetworkManager establishes a connection, the NetworkManager service status becomes 'started'. This is obviously a very bad choice of words by the OpenRC/NetworkManager developers, but this is how it is.

The piavpn service does not recognize 'inactive' status of NetworkManager, and starts only when the status of NetworkManager becomes 'started'. Because of that there is a time gap between the moment when NetworkManager has established a connection to the internet and the time when PIA app starts. During this time every app is able to connect directly without VPN (the killswitch starts working only after the PIA app has started).

Solution

The piavpn service should recognize that NetworkManager has started also when its status is 'inactive'. It will also make the connection to the VPN quicker, since the PIA app would start earlier.

I understand that Gentoo is not officially supported. I hope fixing this very small issue would be fine.

vsvjoirwv commented 3 years ago

I have found a walkaround that helps to avoid this problem. Comment these three lines in /etc/init.d/piavpn:

depend() {

 need net

}

i.e. to get this


#depend() {

# need net

#}

After that service doesn't check if the NetworkManager is up and works as it supposed to. I don't know if it is good and safe as a permanent solution. I hope to get some feedback about it.

JonathonH-PIA commented 3 years ago

Thanks for all the detailed info @vsvjoirwv ! This seems like a logical change given the behavior that you describe for NetworkManager in Gentoo, and the PIA daemon shouldn't require the network to actually be up at startup anyway any more. We detect network configuration changes on the fly now for split tunnel and other cases where that is relevant. (We used to detect network configuration only right before connecting in some older releases.)

I'll see if we can get this tested and included for one of our next few releases. The OpenRC change is pretty limited in scope since none of our fully-supported distributions use OpenRC. We still have a network-online dependency in the systemd service too that I don't think we need any more either.

If you want to try building an installer with the change you've suggested, the OpenRC install script is in extras/installer/linux/installfiles/piavpn.openrc.service - if you have the dependencies set up per the Readme, just rake installer VARIANT=release to get a release installer artifact.

vsvjoirwv commented 3 years ago

Dear @JonathonH-PIA, thank you for the reply. Unfortunately, I didn't understand your last sentence. I have zero experience in app development and programming, even though I use gentoo. I don't think I am capable of doing anything else here.

I hope these three lines will be removed in the next release, since they are not needed anymore.

JonathonH-PIA commented 3 years ago

This change was included in 2.9.0 @vsvjoirwv , thanks for the suggestion and detailed analysis!