Rafficer / linux-cli-community

Linux command-line client for ProtonVPN. Written in Python.
https://protonvpn.com
GNU General Public License v3.0
1.31k stars 198 forks source link

[BUG] Running with systemd user service results into `There is no stored session. Please, login first.` #289

Open Mikaela opened 3 years ago

Mikaela commented 3 years ago

Describe the bug

When starting ProtonVPN from systemd user service on login, it fails to start due to There is no stored session. Please, login first.

To Reproduce

  1. protonvpn-cli login username
  2. cd ~/.config/systemd/user/ (mkdir it if it doesn't exist)
  3. Create a protonvpn-user.service with your favourite text editor.
  4. systemctl --user daemon-reload
  5. systemctl --user enable protonvpn-user.service
  6. reboot
  7. systemctl --user status protonvpn-user.service
[Unit]
Description=ProtonVPN connection
After=network-online.target dbus.socket
Wants=network-online.target dbus.socket

[Service]
Type=forking
ExecStart=protonvpn-cli connect --p2p

[Install]
WantedBy=default.target

Expected behavior

I expect that ProtonVPN starts on login and connects to a server.

Error Messages/Program Output/Log Messages (~/.pvpn-cli/pvpn-cli.log)

● protonvpn-user.service - ProtonVPN connection
     Loaded: loaded (/home/mikaela/.config/systemd/user/protonvpn-user.service; enabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Fri 2021-02-26 16:12:35 EET; 13min ago
        CPU: 540ms

Feb 26 16:12:29 ZALDARYN systemd[1541]: Starting ProtonVPN connection...
Feb 26 16:12:35 ZALDARYN protonvpn-cli[1553]: There is no stored session. Please, login first.
Feb 26 16:12:35 ZALDARYN systemd[1541]: protonvpn-user.service: Control process exited, code=exited, status=1/FAILURE
Feb 26 16:12:35 ZALDARYN systemd[1541]: protonvpn-user.service: Failed with result 'exit-code'.
Feb 26 16:12:35 ZALDARYN systemd[1541]: Failed to start ProtonVPN connection.

Desktop (please complete the following information):

Additional context

After login I can run systemctl --user start protonvpn-cli or protonvpn c and it will work. protonvpn login username informs me that I am already logged in.

There is no full disc encryption (no home directory encryption, no partition encryption). This is a shared family system, so I don't wish to use a system-wide service as the other users aren't supposed to get connected to a VPN.

Mikaela commented 3 years ago

Workaround: ExecStartPre=sleep 60 before ExecStart.

calexandru2018 commented 3 years ago

Hey @Mikaela

The official CLI does not support auto-connect at the given moment. Any custom implementation should done so at own risk.