I have a question related to user permissions in python. I have a project that uses the file system to store information about specific tasks. Of course this can be edited/deleted if user wants to. Now say a user starts the program using sudo sh start.sh. He then does some operations and data is stored. Now if anyone else or even the same user will start the program without sudo rights when trying to delete/modify those file a permission denied OSError is raised. Now this seems logical but my question is:
-
Does python offer any way to choose the permissions when writing/creating a file/folder? More precisely can you create files that will be accessible to all users from sudo ?
-
Does python offer any way to request a users permission when starting the program/ during program execution?
Regards,
Bogdan
Looks like you need
os.fchown().I don’t know what you mean by your second question – do you want to ask for a root password and use it to gain access to a file that the normal user wouldn’t have access to?