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

Encountering "The handle is invalid" error when using subprocess.Popen with shell=True #56

Open
karl-an opened this issue Feb 27, 2024 · 0 comments

Comments

@karl-an
Copy link

karl-an commented Feb 27, 2024

Description

I'm encountering an error when using nordvpn_switcher to interact with the NordVPN application. I run it from RStudio. Freshly installed Python. The error message is:

OSError: [WinError 6] The handle is invalid

This error occurs specifically in the initialize_VPN function on line 152 of nordvpn_switch.py. The relevant code snippet is:

open_nord_win = subprocess.Popen(["nordvpn", "-d"], shell=True, cwd=cwd_path, stdout=DEVNULL)

I understand the security concerns associated with using shell=True and have explored alternative approaches. I've reviewed the documentation but haven't found a documented method to bypass external commands for running NordVPN actions.

Steps to reproduce:

  1. Install nordvpn_switcher.
  2. Run a script that utilizes nordvpn_switcher and attempts to connect or disconnect using the library.

Expected behavior:

The nordvpn_switcher library should successfully interact with the NordVPN application without encountering any errors.

Actual behavior:

The script throws the "The handle is invalid" error when the initialize_VPN function attempts to run the nordvpn command using subprocess.Popen with shell=True.

Additional context:

  • I'm using nordvpn_switcher version 20240228.
  • I'm running the script on a Windows system 10.

I would appreciate any guidance or assistance in resolving this issue.

Thank you for your time and support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant