Nov-12-2020, 03:28 PM
Quote:Use SU from within the script without having to enter a password
Then you've to provide a password in your script or in an additional file.
This is a big security issue.
Quote:editing sudoers from a script to make the installation of the scripts easier?For the user it's easier, but the user needs root access to edit the soduers file.
So, Python needs root access to edit /etc/sudoers.
The Best way is to let the user edit his sudoers if he wants to.
Then just run all your commands which requires root with sudo.
import subprocess def sudo(command): return subprocess.run(["sudo"] + command, capture_output=True, encoding="utf8")The user has to enter his password only once. Then it's cached with an expiration time.
If he is not in sudoers, he is not allowed to gain root rights.
You can argue with security.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!