How To Prevent A Python Script From Running As Root

At or near the top of your app, before it executes anything sensitive, place the following code:

if os.geteuid()==0:
    print "Cannot run as root!"
    sys.exit(1)

How to do this in PERL: …how-to-prevent-a-perl-script-from-running-as-root…

Did you find this post useful or have questions or comments? Please let me know!

This entry was posted in How Tos, Programming, python. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *