Page 1 of 1

Running a socket C prrogram

Posted: Mon Nov 10, 2008 11:54 pm
by kollurivamsy
Hi,

I have a php web page. I need to run a C program which creates a socket and sends an IP packet to another machine. The C program is working fine.

I am using the exec command in my php script to run this program from the script. But the problem is when I run this script on the shell by giving sudo php<filename> , it runs fine and send the ip packet. But when I run it in a browser, the c program is not being run. I think it is a problem with some permissions. When I checked the error log I get the message, Error creating socket. But it runs fine without any errors from the shell. Please help me regarding this.

Re: Running a socket C prrogram

Posted: Tue Nov 11, 2008 6:04 am
by VladSun
Yhat's because you execute the socket program unser Apache user permissions.
Two solutions:
1) Create a socket with port number > 1024, so no root access is required;
2) Use properly configured sudo - i.e. grant sudo to Apache user, so it could create a socket with port number < 1024.