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

only ask for sudo password when required #483

Closed
epheo opened this issue Feb 15, 2024 · 0 comments · Fixed by #484
Closed

only ask for sudo password when required #483

epheo opened this issue Feb 15, 2024 · 0 comments · Fixed by #484
Labels
enhancement New feature or request triage Needs to be reviewed and assigned

Comments

@epheo
Copy link
Contributor

epheo commented Feb 15, 2024

Most desktop Linux distributions do not require sudo privileges to control networking.

nmcli takes its permission from Polkit
/usr/share/polkit-1/actions/org.freedesktop.NetworkManager.policy

I'd like OpenGoPro Python SDK to only ask for sudo privileges when necessary.

One way to implement this would be to:

  • check that the user has sufficient privileges using nmcli general permissions
  • ask for sudo password if not

Attaching a PR.

@epheo epheo added the enhancement New feature or request label Feb 15, 2024
@github-actions github-actions bot added the triage Needs to be reviewed and assigned label Feb 15, 2024
epheo added a commit to epheo/OpenGoPro that referenced this issue Feb 15, 2024
Check nmcli permissions and only ask for password if required.

Move getpass to separate func and validate password input using assert
Otherwise raise AssertionError

Change sudo func to return an empty string if no sudo password is
provided in order to prevent formating of the nmcli commands with sudo
prefix if not required.
Raise condition is moved at password input.

This commit solves gopro#483
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage Needs to be reviewed and assigned
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant