Skip to content
Advertisement

Root autentication on a Python program

I have the root password saved in a variable. How I can give the root authorization at my program?

This can be an example:

JavaScript

Advertisement

Answer

It is impossible to do it in the way you try. Your program is already started under some non-root user and you cannot change it inside this program. You can spawn other process which will be run under the name of root using sudo.

JavaScript

See also this question (from where the code snipped is taken).

Advertisement