Skip to content

protun: first connection after boot always fails with AuthDenied — NM's NeedSecrets call never reaches the newly started nm-protun-service #31

Description

@eraezor

Summary

On a fresh boot, the first connect with the protun-smart protocol always fails after
exactly 10 s with AuthDenied. NetworkManager's NeedSecrets D-Bus call to the plugin
times out: the plugin registers its bus name, but the call is never dispatched to it.
Clicking Connect a second time in the same boot works, as does every later connect.
There is no real authentication problem.

A follow-on bug: when the failure happens during connect_at_app_startup, the app is left
in a wedged state (see "Secondary issue" below).

Environment

  • CachyOS (Arch-based), kernel 7.2.7-1-cachyos, KDE Plasma 6.7.5 (Wayland)
  • NetworkManager 1.58.1
  • proton-vpn-gtk-app 4.18.1 (Arch extra)
  • python-proton-vpn-api-core 5.6.10 (ships /usr/lib/nm-protun-service, nm-protun.name)
  • proton-vpn-daemon 0.13.8, python-proton-core 0.7.4, python-proton-keyring-linux 0.2.3
  • Protocol: protun-smart, kill switch: on (non-permanent)

Steps to reproduce

  1. Reboot.
  2. Open the app (autostart or manually; connect_at_app_startup on or off makes no difference).
  3. Click Connect → it fails after 10 s with "authentication error".
  4. Click Connect again → it connects within about 1 s.

Reproduced on two consecutive boots. In both, the plasma-nm secret agent
(org.kde.plasma.networkmanagement) had registered with NM 47 s and 15 s before the
failing connect, so this does not look like a secret-agent readiness race at login. Also,
the call that times out is NM → plugin, not NM → agent.

Logs — failing (first attempt after boot)

21:01:33.784400 NetworkManager[763]: vpn[...,"ProtonVPN AU#143"]: starting protun
21:01:33.791368 NetworkManager[5464]: INFO proton_vpn_platform::protun::nm_protun_service::run] Starting Proton VPN NetworkManager plugin
21:01:33.793056 NetworkManager[5464]: INFO zbus::connection] start_object_server; started_event=None
21:01:33.793342 NetworkManager[5464]: INFO zbus::connection] monitor_name_lost; name=org.freedesktop.NetworkManager.protun
21:01:33.793378 NetworkManager[5464]: INFO ...::run] Plugin registered at /org/freedesktop/NetworkManager/VPN/Plugin with service name org.freedesktop.NetworkManager.protun
21:01:33.793378 NetworkManager[5464]: INFO ...::run] Waiting for NetworkManager connections...
            <-- no dispatch_call for 10 s -->
21:01:43.793975 NetworkManager[763]: <warn> vpn[...,"ProtonVPN AU#143"]: plugin NeedSecrets request #1 failed: Timeout was reached
21:01:43.794457 NetworkManager[5464]: INFO zbus::object_server] dispatch_call; ... member: "Disconnect"
21:01:43.795223 NetworkManager[5464]: ERROR ...::service] Failed to teardown routing: Received a netlink error message No such device (os error 19)
21:01:43.794725 protonvpn-app: WARNING | Reached connection error state: AuthDenied (None)
21:01:43.796055 protonvpn-app: ERROR | APP:ERROR | Reconnection not possible due to authentication error.

Logs — working (second click, same boot, same NM process, same server)

21:04:03.466380 NetworkManager[763]: vpn[...,"ProtonVPN AU#143"]: starting protun
21:04:03.469703 NetworkManager[7022]: INFO ...::run] Starting Proton VPN NetworkManager plugin
21:04:03.470316 NetworkManager[7022]: INFO ...::run] Plugin registered at /org/freedesktop/NetworkManager/VPN/Plugin ...
21:04:03.470965 NetworkManager[7022]: INFO zbus::object_server] dispatch_call; ... member: "NeedSecrets"
21:04:03.471071 NetworkManager[7022]: INFO ...::network_manager] Secrets are needed for this connection
21:04:03.475131 NetworkManager[7022]: INFO zbus::object_server] dispatch_call; ... member: "NeedSecrets"
21:04:03.475577 NetworkManager[7022]: INFO zbus::object_server] dispatch_call; ... member: "ConnectInteractive"
21:04:03.487038 protonvpn-app: CONN:STATE_CHANGED | Connected

Same NM process (PID 763), same server, 2.5 minutes apart. In the working case NeedSecrets
is dispatched about 0.7 ms after the plugin registers. In the failing case it never arrives,
although the plugin log looks identical up to that point. This looks like a startup race:
NM probably sends NeedSecrets before the plugin's zbus object server is serving the path
(or before the name is fully acquired), and the call is lost instead of being queued or
rejected. The previous boot showed the same pattern (first attempt failed, later ones worked).
It seems tied to the first plugin launch after boot (cold cache), but that part is a guess.

Secondary issue: the app wedges if this happens during connect_at_app_startup

When the failure above happens during the startup auto-connect:

  • the first app instance stays alive in the tray in an error state, and relaunching from
    the launcher shows no window;
  • each relaunch adds another non-persistent pvpn-killswitch dummy connection in NM, because
    the leftover one still owns pvpnksintrf0, then times out after 10 s and exits:
File ".../vpnconnector.py", line 294, in initialize_state
  await self._apply_kill_switch_setting(StateContext.kill_switch_setting)
File ".../wgkillswitch.py", line 74, in enable
  await self._ks_handler.add_kill_switch_connection(permanent)
File ".../killswitch_connection_handler.py", line 56, in _wrap_future
  return await asyncio.wait_for(
TimeoutError

nmcli showed four pvpn-killswitch connections plus a stale ProtonVPN SG#214.
Recovery: kill the app, nmcli con delete every pvpn-killswitch / ProtonVPN * connection,
ip link del pvpnksintrf0, relaunch.

Expected

  • The first connect after boot succeeds, or at least retries NeedSecrets instead of
    reporting a fatal AuthDenied.
  • A plugin/NM timeout is not reported to the user as an authentication error.
  • On startup the app cleans up or reuses existing pvpn-killswitch connections instead of
    piling up duplicates and exiting.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions