Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deactivate doesn't work for CLI #467

Closed
paulmelis opened this issue Mar 22, 2022 · 6 comments
Closed

Deactivate doesn't work for CLI #467

paulmelis opened this issue Mar 22, 2022 · 6 comments
Labels
bug planned-go Planned to be fixed with the Go library
Milestone

Comments

@paulmelis
Copy link

Installation

From this repo, per instructions in readme

Version

45c58ec

OS/Distribution

Arch Linux

Logs

(venv) melis@juggle 11:15:~/c/python-eduvpn-client$ eduvpn-cli activate
INFO:eduvpn.remote:Requesting https://surf.eduvpn.nl/.well-known/vpn-user-portal
INFO:eduvpn.storage:updating token for https://surf.eduvpn.nl/
INFO:eduvpn.nm:calling action with CLI mainloop
INFO:eduvpn.nm:activate_connection uuid: c13b19c5-3dbf-485b-b353-8a9be1d55caa connection: <NM.RemoteConnection object at 0x7fb6800df340 (NMRemoteConnection at 0x5620032f4710)>
INFO:eduvpn.nm:activate_connection_async result: <NM.VpnConnection object at 0x7fb67dde9cc0 (NMVpnConnection at 0x56200327d240)>
INFO:eduvpn.nm:Quiting main loop, thanks!
(venv) melis@juggle 11:15:~/c/python-eduvpn-client$ eduvpn-cli status


# Global configuration

uuid: c13b19c5-3dbf-485b-b353-8a9be1d55caa
auth_url: https://surf.eduvpn.nl/
VPN connection active: False
VPN NM status is: None
Active VPN connection is EduVPN: False


## Previous connection properties

 ** CURRENT ACTIVE CONFIGURATION **
auth_url https://surf.eduvpn.nl/
api_url: https://surf.eduvpn.nl/portal/api.php/v3
display_name: SURF BV
support_contact: ['https://support.ia.surf.nl/']
profile_id: medewerkers
token_endpoint: https://surf.eduvpn.nl/portal/oauth.php/token
authorization_endpoint: https://surf.eduvpn.nl/portal/_oauth/authorize
con_type: INSTITUTE
country_id: None
token.token_type: bearer
token.expires_in: 3600
token.expires_at: 1647947540.9699554


(venv) melis@juggle 11:20:~/c/python-eduvpn-client$ eduvpn-cli deactivate
INFO:eduvpn.nm:calling action with CLI mainloop
<hangs and VPN stays active>
<after pressing Ctl-C:>

^CTraceback (most recent call last):
  File "/home/melis/c/python-eduvpn-client/venv/bin/eduvpn-cli", line 33, in <module>
    sys.exit(load_entry_point('eduvpn-client==2.2.1', 'console_scripts', 'eduvpn-cli')())
  File "/home/melis/c/python-eduvpn-client/eduvpn/cli.py", line 139, in eduvpn
    parse_eduvpn(argv[1:])
  File "/home/melis/c/python-eduvpn-client/eduvpn/cli.py", line 105, in parse_eduvpn
    parsed.func(parsed)
  File "/home/melis/c/python-eduvpn-client/eduvpn/cli.py", line 34, in deactivate
    actions.deactivate()
  File "/home/melis/c/python-eduvpn-client/eduvpn/actions.py", line 137, in deactivate
    deactivate_connection_with_mainloop(get_uuid())
  File "/home/melis/c/python-eduvpn-client/eduvpn/nm.py", line 439, in deactivate_connection_with_mainloop
    action_with_mainloop(action=lambda callback: deactivate_connection(get_client(), uuid, callback))
  File "/home/melis/c/python-eduvpn-client/eduvpn/nm.py", line 426, in action_with_mainloop
    main_loop.run()
  File "/home/melis/c/python-eduvpn-client/venv/lib/python3.10/site-packages/gi/overrides/GLib.py", line 495, in run
    with register_sigint_fallback(self.quit):
  File "/usr/lib/python3.10/contextlib.py", line 142, in __exit__
    next(self.gen)
  File "/home/melis/c/python-eduvpn-client/venv/lib/python3.10/site-packages/gi/_ossighelper.py", line 237, in register_sigint_fallback
    signal.default_int_handler(signal.SIGINT, None)
KeyboardInterrupt

When using eduvpn-gui to do the same steps I get this error (and the VPN connection stays active):

(venv) melis@juggle 11:18:~/c/python-eduvpn-client$ eduvpn-gui 
2022-03-22 11:18:41,211 - MainThread - INFO - eduvpn.ui.ui - ui.py:580 - selection empty
2022-03-22 11:18:41,211 - MainThread - INFO - eduvpn.ui.ui - ui.py:580 - selection empty
2022-03-22 11:18:41,212 - MainThread - INFO - eduvpn.ui.ui - ui.py:580 - selection empty
2022-03-22 11:18:41,226 - init-server-db - INFO - eduvpn.remote - remote.py:23 - Requesting https://disco.eduvpn.org/v2/server_list.json
2022-03-22 11:18:41,368 - init-server-db - INFO - eduvpn.remote - remote.py:37 - Retrieving signature https://disco.eduvpn.org/v2/server_list.json.minisig
2022-03-22 11:18:41,479 - init-server-db - INFO - eduvpn.remote - remote.py:44 - verifying signature of https://disco.eduvpn.org/v2/server_list.json
2022-03-22 11:18:41,480 - init-server-db - INFO - eduvpn.remote - remote.py:23 - Requesting https://disco.eduvpn.org/v2/organization_list.json
2022-03-22 11:18:41,659 - init-server-db - INFO - eduvpn.remote - remote.py:37 - Retrieving signature https://disco.eduvpn.org/v2/organization_list.json.minisig
2022-03-22 11:18:41,777 - init-server-db - INFO - eduvpn.remote - remote.py:44 - verifying signature of https://disco.eduvpn.org/v2/organization_list.json
2022-03-22 11:18:42,845 - MainThread - INFO - eduvpn.ui.ui - ui.py:580 - selection empty
2022-03-22 11:18:42,845 - MainThread - INFO - eduvpn.ui.ui - ui.py:580 - selection empty
2022-03-22 11:18:42,846 - oauth-refresh - INFO - eduvpn.remote - remote.py:23 - Requesting https://surf.eduvpn.nl/.well-known/vpn-user-portal
2022-03-22 11:18:43,002 - load-server-info - INFO - eduvpn.remote - remote.py:23 - Requesting https://surf.eduvpn.nl/.well-known/vpn-user-portal
2022-03-22 11:18:43,129 - configure-connection - INFO - eduvpn.remote - remote.py:23 - Requesting https://surf.eduvpn.nl/.well-known/vpn-user-portal
2022-03-22 11:18:43,362 - MainThread - INFO - eduvpn.nm - nm.py:265 - writing ovpn configuration to Network Manager
2022-03-22 11:18:43,362 - MainThread - INFO - eduvpn.nm - nm.py:188 - Writing configuration to /tmp/tmpbfeg_wqz/eduVPN.ovpn
2022-03-22 11:18:43,558 - MainThread - INFO - eduvpn.nm - nm.py:221 - Updating existing connection with new configuration
2022-03-22 11:18:43,580 - MainThread - INFO - eduvpn.interface.event - event.py:187 - Finished saving network manager config: <Gio.Task object at 0x7fcbe37ad300 (GTask at 0x55cd21e02100)>
2022-03-22 11:18:43,583 - MainThread - INFO - eduvpn.nm - nm.py:354 - setting default gateway: False
2022-03-22 11:18:43,601 - MainThread - INFO - eduvpn.nm - nm.py:286 - activate_connection uuid: c13b19c5-3dbf-485b-b353-8a9be1d55caa connection: <NM.RemoteConnection object at 0x7fcbe37ac740 (NMRemoteConnection at 0x55cd21d011f0)>
2022-03-22 11:18:43,675 - MainThread - INFO - eduvpn.nm - nm.py:301 - activate_connection_async result: <NM.VpnConnection object at 0x7fcbe045fa40 (NMVpnConnection at 0x55cd21f81370)>

<deactivate in GUI with the 0/1 switch>

2022-03-22 11:18:53,305 - stop-connection - INFO - eduvpn.remote - remote.py:23 - Requesting https://surf.eduvpn.nl/.well-known/vpn-user-portal
Traceback (most recent call last):
  File "/home/melis/c/python-eduvpn-client/eduvpn/ui/ui.py", line 616, in on_switch_connection_state
    self.app.interface_transition('deactivate_connection')
  File "/home/melis/c/python-eduvpn-client/eduvpn/app.py", line 172, in interface_transition
    self._base_transition(
  File "/home/melis/c/python-eduvpn-client/eduvpn/app.py", line 133, in _base_transition
    state_machine.transition(
  File "/home/melis/c/python-eduvpn-client/eduvpn/state_machine.py", line 174, in transition
    new_state = transition_func(*args, **kwargs)
  File "/home/melis/c/python-eduvpn-client/eduvpn/interface/state.py", line 364, in deactivate_connection
    app.network_transition('disconnect')
  File "/home/melis/c/python-eduvpn-client/eduvpn/app.py", line 148, in network_transition
    self._base_transition(
  File "/home/melis/c/python-eduvpn-client/eduvpn/app.py", line 133, in _base_transition
    state_machine.transition(
  File "/home/melis/c/python-eduvpn-client/eduvpn/state_machine.py", line 176, in transition
    with self.trigger_callbacks(old_state, new_state):
  File "/usr/lib/python3.10/contextlib.py", line 142, in __exit__
    next(self.gen)
  File "/home/melis/c/python-eduvpn-client/eduvpn/state_machine.py", line 188, in trigger_callbacks
    self._call_edge_callbacks(ENTER, old_state, new_state)
  File "/home/melis/c/python-eduvpn-client/eduvpn/state_machine.py", line 262, in _call_edge_callbacks
    callback(old_state, new_state)
  File "/home/melis/c/python-eduvpn-client/eduvpn/ui/app.py", line 153, in enter_DisconnectedState
    self.connection_notification.hide()
  File "/home/melis/c/python-eduvpn-client/eduvpn/notify.py", line 32, in hide
    self.notification.close()  # type: ignore
gi.repository.GLib.GError: notification-daemon-error-quark: GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._notification_2ddaemon_2derror_2dquark.Code100: 0 is not a valid notification ID (100)

I see no messages in the journalctl output when I run the deactivate command, seems to get stuck before doing anything.

@hurngchunlee
Copy link

Hi, I also run into the same issue when I don't make the eduVPN the default route in the NetworkManager configuration (i.e. having never-default=true).

After checking the code, I suspect that it is probably due to the fact that the deactivate uses get_primary_connection() of the NetworkManager to get the connection (see https://github.com/eduvpn/python-eduvpn-client/blob/master/eduvpn/nm.py#L310).

According to this document, the get_primary_connection doesn't return the VPN connection if it doesn't have the default route.

@alvra
Copy link
Collaborator

alvra commented Mar 22, 2022

Looks like these are actually all separate issues around deactivation:

I can't speak on the cli, but for the gui issue we'll probably need more details on your unique setup and how to reproduce this. Can you create a separate issue and add this information?

@paulmelis
Copy link
Author

I can't speak on the cli, but for the gui issue we'll probably need more details on your unique setup and how to reproduce this. Can you create a separate issue and add this information?

Done, see #467

@gijzelaerr
Copy link
Collaborator

@paulmelis you are linking to this issue, you probably meant #469

@gijzelaerr gijzelaerr changed the title Deactivate doesn't work Deactivate doesn't work for CLI Apr 22, 2022
@gijzelaerr gijzelaerr added this to the 2.4 milestone Apr 22, 2022
@gijzelaerr gijzelaerr added the bug label Apr 22, 2022
@paulmelis
Copy link
Author

@paulmelis you are linking to this issue, you probably meant #469

Ah, yes, my bad, sorry

@jwijenbergh jwijenbergh added the planned-go Planned to be fixed with the Go library label Jun 13, 2022
@jwijenbergh
Copy link
Collaborator

Fixed in version 4, install instructions https://python-eduvpn-client.readthedocs.io/en/latest/installation.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug planned-go Planned to be fixed with the Go library
Projects
None yet
Development

No branches or pull requests

5 participants