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

[BUG] Python protonvpn-cli: Old user-level installation causes new root installation to raise an error, since it tries to look at the user-level ~/.-pvpn-cli file instead of the root level one #378

Open
dmentock opened this issue Jan 2, 2025 · 1 comment

Comments

@dmentock
Copy link

dmentock commented Jan 2, 2025

I originally installed protonvpn-cli simply with pip in my local environment as a regular user, just to see that it requires sudo priviliges. I then logged in as root and reinstalled protonvpn-cli, but now I get the error

% sudo protonvpn 
Traceback (most recent call last):
  File "/usr/local/bin/protonvpn", line 5, in <module>
    from protonvpn_cli.cli import main
  File "/usr/local/lib/python3.12/dist-packages/protonvpn_cli/cli.py", line 59, in <module>
    from . import connection
  File "/usr/local/lib/python3.12/dist-packages/protonvpn_cli/connection.py", line 15, in <module>
    from .logger import logger
  File "/usr/local/lib/python3.12/dist-packages/protonvpn_cli/logger.py", line 40, in <module>
    logger = get_logger()
             ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/protonvpn_cli/logger.py", line 20, in get_logger
    os.mkdir(CONFIG_DIR)
PermissionError: [Errno 13] Permission denied: '/home/my_local_user/.pvpn-cli'

I assume that the first installation wrote something to some global file, which is now picked up by the new root installation and causes it to look at the '/home/my_local_user/.pvpn-cli' directory instead of the root home directory. Is there anythinig we can do to ensure it cleanly uninstalls?

@dmentock
Copy link
Author

dmentock commented Jan 3, 2025

The problem was the username detection in /usr/local/lib/python3.12/dist-packages/protonvpn_cli/logger.py . Doing

    if os.geteuid() == 0:
        return 'root'
    else:
        if "SUDO_USER" in os.environ:
...

worked as a hotfix, maybe there is a more elegant solution to this problem? I assume I am not the only one who encountered this.

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