{"id":259,"date":"2013-10-21T10:01:55","date_gmt":"2013-10-21T15:01:55","guid":{"rendered":"http:\/\/www.popmartian.com\/tipsntricks\/?p=259"},"modified":"2013-10-21T10:01:55","modified_gmt":"2013-10-21T15:01:55","slug":"how-to-prevent-a-python-script-from-running-as-root","status":"publish","type":"post","link":"https:\/\/www.popmartian.com\/tipsntricks\/2013\/10\/21\/how-to-prevent-a-python-script-from-running-as-root\/","title":{"rendered":"How To Prevent A Python Script From Running As Root"},"content":{"rendered":"<p>At or near the top of your app, before it executes anything sensitive, place the following code:<\/p>\n<p><code>if os.geteuid()==0:<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;print \"Cannot run as root!\"<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;sys.exit(1)<\/code><\/p>\n<p>How to do this in PERL: <a title=\"...how-to-prevent-a-perl-script-from-running-as-root...\" href=\"http:\/\/www.popmartian.com\/tipsntricks\/2011\/03\/29\/how-to-prevent-a-perl-script-from-running-as-root\/\">&#8230;how-to-prevent-a-perl-script-from-running-as-root&#8230;<\/a><\/p>\n<blockquote><p>Did you find this post useful or have questions or comments? Please let me know!<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>At or near the top of your app, before it executes anything sensitive, place the following code: if os.geteuid()==0: &nbsp;&nbsp;&nbsp;&nbsp;print &#8220;Cannot run as root!&#8221; &nbsp;&nbsp;&nbsp;&nbsp;sys.exit(1) How to do this in PERL: &#8230;how-to-prevent-a-perl-script-from-running-as-root&#8230; Did you find this post useful or have &hellip; <a href=\"https:\/\/www.popmartian.com\/tipsntricks\/2013\/10\/21\/how-to-prevent-a-python-script-from-running-as-root\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,9,59],"tags":[],"class_list":["post-259","post","type-post","status-publish","format-standard","hentry","category-how-to-do-stuff","category-programming","category-python"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts\/259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/comments?post=259"}],"version-history":[{"count":3,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts\/259\/revisions"}],"predecessor-version":[{"id":262,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts\/259\/revisions\/262"}],"wp:attachment":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/media?parent=259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/categories?post=259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/tags?post=259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}