0

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.

Jose Rodriguez
  • 9,753
  • 13
  • 36
  • 52
gyung june
  • 43
  • 1
  • 7
  • i use cortex-A forwarding linux. the linux doesn't have 'sudo' – gyung june Feb 03 '17 at 04:20
  • 1
    Possible duplicate of [Allowing Apache on EC2 to run sudo commands via CGI script](http://stackoverflow.com/questions/23277891/allowing-apache-on-ec2-to-run-sudo-commands-via-cgi-script) – Grisha Levit Feb 03 '17 at 07:19

0 Answers0