#43731 [NEW]: socket_getpeername: cannot use on stdin with inetd

From: Date: Wed, 02 Jan 2008 19:58:18 +0000
Subject: #43731 [NEW]: socket_getpeername: cannot use on stdin with inetd
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-120994@lists.php.net to get a copy of this message
From: uth3r_p3ndrag0n at yahoo dot com Operating system: Linux, Debian Etch 4.0r1 PHP version: 5.2.5 PHP Bug Type: Sockets related Bug description: socket_getpeername: cannot use on stdin with inetd Description: ------------ When running a php script via inetd, I cannot get the remote address due to socket_getpeername's parameter type. There seems no way to treat the stdin as a socket for this function. The C system call, getpeerbyname (in <sys/socket.h>) takes a file descriptor. When called by inetd, passing 0 (or stdin) returns the peer information of the socket which is mapped to the stdin of the running process. There may not be anyway to work around this considering the way sockets were designed in php. I tried opening php://stdin and using the resource returned, but that isn't a Socket resource. I would have expected to be able get a socket resource of stdin via 'fsockopen("php://stdin")', as specified in http://www.php.net/manual/en/wrappers.php.php, but despite it's url style naming, fsockopen returns 'Unable to find the socket transport "php"' Reproduce code: --------------- $stdin = fopen('php://stdin'); socket_getpeername($stdin, $addr, $port); OR $stdin = fsockopen('php://stdin'); socket_getpeername($stdin, $addr, $port); Expected result: ---------------- $addr and $port should have been populated with the ip address and port #. Actual result: -------------- Warning: socket_getpeername(): supplied resource is not a valid Socket resource in [script name] on line X OR Warning: fsockopen(): unable to connect to php://stdin:-1 (Unable to find the socket transport "php" - did you forget to enable it when you configured PHP?) in [script_name] on line X -- Edit bug report at http://bugs.php.net/?id=43731&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43731&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43731&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43731&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43731&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43731&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43731&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43731&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43731&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43731&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43731&r=support Expected behavior: http://bugs.php.net/fix.php?id=43731&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43731&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43731&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43731&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43731&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43731&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43731&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43731&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43731&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43731&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43731&r=mysqlcfg

« previous php.bugs (#120994) next »