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

Unable to run as user (PATH issue) #187

Open
android-808 opened this issue Aug 19, 2018 · 12 comments
Open

Unable to run as user (PATH issue) #187

android-808 opened this issue Aug 19, 2018 · 12 comments

Comments

@android-808
Copy link

if shutil.which("openvpn") is None or shutil.which("wget") is None or shutil.which("unzip") is None:

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.

@jotyGill
Copy link
Owner

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.

@android-808
Copy link
Author

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.

def run_openvpn(*args):

@android-808
Copy link
Author

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.

@jotyGill
Copy link
Owner

"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

@arichiardi
Copy link

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

@jotyGill
Copy link
Owner

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
Copy link
Owner

If this is sorted, I'll close the issue

@android-808
Copy link
Author

        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?

@arichiardi
Copy link

Yep I don't think this works as it is

@android-808
Copy link
Author

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.

@ranisalt
Copy link
Contributor

Have a look at #225

@android-808
Copy link
Author

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.

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

4 participants