openpyn-nordvpn
openpyn-nordvpn copied to clipboard
Unable to run as user (PATH issue)
https://github.com/jotyGill/openpyn-nordvpn/blob/d329ec295226345957d6c8ea809440b949ff0667/openpyn/openpyn.py#L232
OS: Debian Sid
Having seen a number of warnings regarding notification support when run via sudo, I have attempted to run the app as my normal user. Startup fails however performing the checks linked above.
All the apps reside in /usr/bin except for openvpn which is in /usr/sbin, which isn't stored PATH, so fails the 'which' test.
If openvpn is not in your PATH, that is a problem. even If we skip the which test, it needs to be run from openpyn. You have to add it to your PATH.
The issue is 'which' is testing the users PATH. The command itself is not, as far as I can tell, actually called by that user but by root (via sudo). As a result it is root's PATH that should be tested.
https://github.com/jotyGill/openpyn-nordvpn/blob/d329ec295226345957d6c8ea809440b949ff0667/openpyn/openpyn.py#L885
It now runs without requiring to be started as root/ via sudo.
Is the last of the checks in the patch meant to be commented? Running "sudo which openvpn" does produce a valid path ("/usr/sbin/openvpn"). I have been trying to find the default PATH for a number of other distros to see if this is unique to Debian or if it affects other distros as well.
"Is the last of the checks in the patch meant to be commented? Running "sudo which openvpn" does produce a valid path ("/usr/sbin/openvpn")" Yes. If the programs are not in users PATH they are being looked in root's PATH, if they are not there as well then openpyn would suggest to install them. Cool, let me know what you find
I have a similar problem when running sudo openpyn --init after having installed with pip install --user:
File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3105, in <module>
@_call_aside
File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3089, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3118, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 578, in _build_master
ws.require(__requires__)
File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 895, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 781, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'openpyn==2.7.5' distribution was not found and is required by the application
Do not install it with --user. When you run "sudo openpyn". root account has no clue where it is.
uninstall it using sudo python3 -m pip uninstall openpyn then reinstall it sudo python3 -m pip install --upgrade openpyn
If this is sorted, I'll close the issue
subprocess.check_output(["sudo", "which", "wget"])
subprocess.check_output(["sudo", "which", "unzip"])
# subprocess.check_output(["sudo", "which", "openvpn"])
I know as you said it prompts for installation, but being commented won't the last line pass anyway without openvpn being present?
Yep I don't think this works as it is
Just a quick update. Buster introduces /sbin and /bin merged with /usr/sbin and /usr/bin by default. The usrmerge package in Sid allows you to convert existing system. Unfortunately the default path still doesn't include /sbin or /usr/sbin so which openvpn still needs to be run via sudo.
Have a look at #225
The main issue is OpenVPN. unzip and wget are available in user path regardless of merged /usr (usrmerge) or not. OpenVPN being in /usr/sbin or /sbin on Debian is the reason for needing check via sudo. #255 looks to prevent a lot of the root requirements but unfortunately in its current form doesn't solve this issue.
On a more positive note, apparently when OpenVPN 3 comes along it'll bring a dbus interface for handling connections as well as python support. Apparently this means root will not be required.