openpyn-nordvpn icon indicating copy to clipboard operation
openpyn-nordvpn copied to clipboard

Unable to run as user (PATH issue)

Open android-808 opened this issue 7 years ago • 12 comments

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.

android-808 avatar Aug 19 '18 09:08 android-808

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.

jotyGill avatar Aug 20 '18 03:08 jotyGill

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

android-808 avatar Aug 20 '18 06:08 android-808

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.

android-808 avatar Sep 16 '18 15:09 android-808

"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

jotyGill avatar Sep 17 '18 03:09 jotyGill

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

arichiardi avatar Sep 21 '18 04:09 arichiardi

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

jotyGill avatar Sep 21 '18 04:09 jotyGill

If this is sorted, I'll close the issue

jotyGill avatar Sep 27 '18 00:09 jotyGill

        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?

android-808 avatar Sep 27 '18 05:09 android-808

Yep I don't think this works as it is

arichiardi avatar Sep 27 '18 16:09 arichiardi

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.

android-808 avatar Jan 17 '19 23:01 android-808

Have a look at #225

ranisalt avatar Jan 30 '19 21:01 ranisalt

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.

android-808 avatar Feb 03 '19 20:02 android-808