Jump to content

Ritesh_Prajapati

Members
  • Posts

    3
  • Joined

  • Last visited

Ritesh_Prajapati's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have debug using strace and found following log while running php based socket file on command prompt. socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = -1 EACCES (Permission denied) Do you have any idea how to solve this issue?
  2. I haven't support of SE linux in my board. That's why i can not able to solve this problem uszing SElinux support. It gives permission denied error while running above problem through web browser which indicates that we can not create socket due to user permission problem for httpd. I have already tried all the way to solve this issue but still failed to solve this issue.
  3. \ I have installed php 5.4.13 on Linux 2.6.34. I have make simple client/server page using socket but it did not work on it. It give permission denied error Below is my php code if (false == ($socket = socket_create(AF_INET, SOCK_STREAM, 0))) // create socket { $stringData= date("D M d, Y g:i A"). " socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "<br>"; echo $stringData; } else { $timeout = array('sec'=>5,'usec'=>500000); socket_set_option($socket,SOL_SOCKET,SO_RCVTIMEO,$timeout); if(false==($result = socket_connect($socket, $host, $port))) { $stringData= date("D M d, Y g:i A"). " socket_connect() failed: reason: " . socket_strerror(socket_last_error()) . "<br>"; echo $stringData; socket_close($socket); } else { $stringData= date("D M d, Y g:i A"). " Socket connected succefully <br>"; echo $stringData; if(false==(socket_write($socket, $command, strlen($command)))) { $stringData= date("D M d, Y g:i A"). " socket_write() failed: reason: " . socket_strerror(socket_last_error()) . "<br>"; echo $stringData; socket_close($socket); } else { if(false===($cmd = socket_read ($socket, 65536))) { //10060 for windows and 11 for linux if(10060!=socket_last_error() && 11!=socket_last_error()) { $stringData= date("D M d, Y g:i A"). " socket_read() failed: reason: " . socket_strerror(socket_last_error()) . "<br>"; echo $stringData; socket_close($socket); } switch(socket_select($r = array($socket), $w = array($socket), $f = array($socket), 5)) { case 2: $refused=1; break; } if($refused==1) { $stringData= date("D M d, Y g:i A"). " socket_read() failed: reason: Connection Refused <br>"; $ourFileHandle = fopen(SOCKET_LOG, 'a'); echo $stringData; socket_close($socket); } } else { echo "<pre>".html_entity_decode(print_r($cmd,true))."</pre>"; } } } } Above code work fine on command prompt but it gives error Permission denied when page open from any browser. Command of run php from terminal : /usr/local/rootfs/php5/bin/php /www/socket_client.php I have found something new related to user permission which can not allow to create socket from web interface. I can run php process from command promt with root user and can able to create socket successfully without any failure cases. can any one have idea how to solve above issue without SElinux support because i don't have SElinux support in my system? Please let me know as soon as possible because its a cusial issue for me to solve and also i have tried with all its possble test-cases regarding permission of php.ini,httpd.conf and whole apache folder to root user permission with 777 but still i can not create soclet while from php file wihle running php file on web interface. I can only create that socket only on command prompt with root user login access. I can not create socket with not-root user. I have also tried to changed root and group in httpd.conf file but still it fails to start httpd process with root user. so is there anyone have idea about what to do with this issue?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.