python - Call subprocess sudo from uwsgi -


i executing sudo statement python on uwsgi. configured account (www-data) not need password sudo not work.

if run shell, works desired account:

www-data@srv sudo iptables -l -n 

but script , uwsgi, prompts password.

in sudoers have:

www-data all=(all) nopasswd: /sbin/iptables 

and in python script:

subprocess.call(['sudo', '/sbin/iptables -l -n']) 

thanks , sorry english.

i tested code on server, alternative :

subprocess.call("sudo" + " /sbin/iptables -l -n", shell=true) 

see https://docs.python.org/2/library/subprocess.html


Comments