I have a Ubuntu 12.04 Custom Board running Apache2. I have a web page which calls a CGI script which is responsible for starting and stopping ipsec service. I access the web page from another machine in local environment. Following is the CGI script that gets called when I press a simple button in UI:
root@localhost:~# busybox cat /usr/lib/cgi-bin/stop-IPSec.cgi
#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Configure IP Address"
echo "</title></head><body>"
echo $(whoami)
echo $(/etc/init.d/ipsec stop)
echo $(su root /etc/init.d/ipsec stop)
echo "</body></html>"
Gives me output:
www-data ipsec_setup: permission denied (must be superuser)
And the following line fails:
echo $(su root /etc/init.d/ipsec stop)
And gives this error in apache error log:
su: must be run from a terminal
And sudo
is not available since I am running Ubuntu Core on board which I intent to use as Wifi Dongle.
I want to stop ipsec service and that requires it to be root. How can this be achieved. Any pointers will make my day.
chmod u+s
<-- look into it.chmod u+s /usr/lib/cgi-bin/stopIPSec.cgi
I have not created any virtual site as in my HTML pages are in/var/www/
folder, could this be an issue?