Is it possible to request root pw without storing a script in my memory and run some os commands. * how root?
My script
- scans some folders and files to see if it can complete the task
- makes some changes to / etc / ...
- creates a folder and files that should belong to the user who ran the script
(1) can be run as a regular user. I can do (2) using a sudoing script, but then the folder and files in (3) will be root.
The problem is that I use a lot of os.makedirs, os.symlink, etc., which prevents me from making it workable as a regular user.
Tanks 2 all for offers
The solution so far:
# do all in sudo
os.chown(folder, int(os.getenv('SUDO_UID')), int(os.getenv('SUDO_GID')))
thanks to the gnibbler hint.