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

Fix sudo issue when using venv #438

Closed
ribalba opened this issue Aug 29, 2023 · 2 comments · Fixed by #444
Closed

Fix sudo issue when using venv #438

ribalba opened this issue Aug 29, 2023 · 2 comments · Fixed by #444

Comments

@ribalba
Copy link
Member

ribalba commented Aug 29, 2023

In the runner we use:

ps = subprocess.run(['sudo', sys.executable, python_file], stdout=subprocess.PIPE, check=True, encoding='UTF-8')

to call the hardware info script and we add an sudoers.d file green_coding_hardware_info with

ALL ALL=(ALL) NOPASSWD:/usr/bin/python3 /home/didi/code/green-metrics-tool/lib/hardware_info_root.py

when using a venv the python paths don't match anymore and we are asked to supply a password. Obviously this is not very nice. We somehow need a solution to include venvs here.

Using a wildcard like

ALL ALL=(ALL) NOPASSWD:*/python3 /home/didi/code/green-metrics-tool/lib/hardware_info_root.py

is not an option as someone could crate a script and call it python3 and then run anything as root.

I would suggest that we modify the install script to use venvs and then also modify the sudoers file.

@ArneTR
Copy link
Member

ArneTR commented Aug 30, 2023

is /usr/bin/env python3 an option?

@ribalba
Copy link
Member Author

ribalba commented Aug 31, 2023

great idea :)

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

Successfully merging a pull request may close this issue.

2 participants