I am working on a cgi
script that should manage adding and deleting
routes in router from a web interface.
I am using the following to delete a route from a cgi
form page
[cgi]
int main()
{
printf("Content-type : text/plain\n\n");
FILE *fp;
int state;
char buff[MAXLINE];
fp = popen("/sbin/route add -net default netmask 255.255.255.0 dev bridge0 2>/WEBSERVER/www/cgi-bin/popen.txt", "r");
if (fp == NULL)
{
perror("erro : ");
exit(0);
}
while(fgets(buff, MAXLINE, fp) != NULL)
{
printf("%s", buff);
}
state = pclose(fp);
printf("state is %d\n", state);
}
But on the popen error logs, I get the following:
route: socket: permission denied
Any ideas?
PS. when just executing cgi file is well without web server, route add very well.
I saw solution that cgi file set chmod 777, or web login as root.