From: bengen+php at hilluzination dot de
Operating system: GNU/Linux
PHP version: 4.3.11
PHP Bug Type: CGI related
Bug description: The -b parameter to the FastCGI binary does accept pathnames
Description:
------------
I would like to start an instance of the FastCGI interpreter which listens
to a Unix Domain socket. libfcgi would this, but the wrapper code in
cgi_main.c differentiates only between
php4-cgi -b $ADDRESS:$PORT
and
php4-cgi -b [:]$PORT
If the colon is missing, it is assumed that the user wants a TCP socket
which is not bound to a specific address and thus a colon is prepended.
This breaks passing a path to a Unix Domain socket.
Fix: Since libfcgi apparently accepts the port only in numeric form
anyhow, I have simply added a check whether the first character of the
argument is a digit. In this case, it is assumed to be a port and
prepended with a colon. If not, it is assumed to be a pathname.
Alternatively, one could altogether remove the code which prepends the
colon and document the behavior.
diff -ui cgi_main.c.orig cgi_main.c
--- cgi_main.c.orig 2005-07-12 15:04:19.000000000 +0200
+++ cgi_main.c 2005-07-12 15:53:48.000000000 +0200
@@ -1140,12 +1140,12 @@
/* this must be done to make FCGX_OpenSocket work correctly
bug 23664 */
close(0);
- /* Pass on the arg to the FastCGI library, with one exception.
- * If just a port is specified, then we prepend a ':' onto the
- * path (it's what the fastcgi library expects)
+ /* Pass on the arg to the FastCGI library, with one exception.
+ * If just a numeric port is specified, then we prepend a ':'
+ * onto the path (it's what the fastcgi library expects)
*/
- if (strchr(bindpath, ':') == NULL) {
+ if ( isdigit(bindpath[0]) && (strchr(bindpath, ':') == NULL) ) {
char *tmp;
tmp = malloc(strlen(bindpath) + 2);
Actual result:
--------------
[EMAIL PROTECTED]:~$ php4-cgi -b /tmp/foo
bind/listen: No such file or directory
Couldn't create FastCGI listen socket on port /tmp/foo
[EMAIL PROTECTED]:~$ echo $?
255
[EMAIL PROTECTED]:~$
--
Edit bug report at http://bugs.php.net/?id=33663&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33663&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=33663&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=33663&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33663&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33663&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33663&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33663&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33663&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33663&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33663&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=33663&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=33663&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33663&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33663&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33663&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33663&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33663&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33663&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33663&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33663&r=mysqlcfg