I am executing a sudo
statement from python over uwsgi. I configured the account (www-data
) to not need a password for sudo
but it does not work.
If I run from shell, it works properly with the desired account:
www-data@srv sudo iptables -L -n
but from my script and uwsgi, it prompts for password.
In sudoers
I have:
www-data ALL=(ALL) NOPASSWD: /sbin/iptables
and in my python script:
subprocess.call(['sudo', '/sbin/iptables -L -n'])
Thanks and sorry for my english.
i tested this code on my server, it could be a good alternative :
subprocess.call("sudo" + " /sbin/iptables -L -n", shell=True)