ID: 33663 User updated by: bengen+php at hilluzination dot de Reported By: bengen+php at hilluzination dot de Status: Bogus Bug Type: CGI related Operating System: GNU/Linux PHP Version: 4.3.11 New Comment:
Sorry about the duplicate bug. For some reason I had not found the other bug report even though I looked. The solution attached to #29574 looks similar, but it is wrong: If the user wants a socket foo created in the working directory, he would just say php4-cgi -b foo, but the php interpreter would still prepend a colon. Previous Comments: ------------------------------------------------------------------------ [2005-07-12 18:05:20] [EMAIL PROTECTED] Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. See bug #29574 ------------------------------------------------------------------------ [2005-07-12 16:17:45] bengen+php at hilluzination dot de Um. "not" added to title. ------------------------------------------------------------------------ [2005-07-12 16:16:21] bengen+php at hilluzination dot de 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 this bug report at http://bugs.php.net/?id=33663&edit=1