Running a socket C prrogram

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
kollurivamsy
Forum Newbie
Posts: 1
Joined: Mon Nov 10, 2008 11:53 pm

Running a socket C prrogram

Post 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.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Running a socket C prrogram

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply