I'm trying execute a python script from php function shell_exec(), but this script require root privileges.
The python code is very simple. Using libraries wifi python does a scan of all the SSID and provides in output the information on the various wireless networks to which he had a scan in JSON format. WiFi libraries are scanning using iwlist that requires root privileges. If it is performed by a user who does not have root privileges, it returns only the information referring to the wifi where you are connected.
If I plug in my code the string
<?php
echo 'Current script owner:'. get_current_user ();
?>
I print screen "Current script owner: root", but if I try to run my code
<?php
$ Output = shell_exec ("python /home/acme/XDOMV2/conn1.py");
echo $ output;
?>
It will only return information about the network on which my debian system is connected. How to use lighttpd webserver and I have followed several guides about getting to the only result of having to re-install lighttpd. The question is, is there a way to run a python script as root from lighttpd? Where am I wrong?
/etc/sudoers), with a normal-user Python script that drives it, run as normal by your PHP, would be a lot safer than having the server run as root so it can run your PHP as root so it can run your Python as root just to call that function.lighttpdis built to prevent it by default because you almost never need to do it this way, even when you think you do, and they want you to have to go out of your way and configure and rebuild the server if you really know what you're doing. If so, then that's what you have to do.get_current_user, and which one you need?