#33663 [Opn]: The -b parameter to the FastCGI binary does not accept pathnames

From: Date: Tue, 12 Jul 2005 14:17:46 +0000
Subject: #33663 [Opn]: The -b parameter to the FastCGI binary does not accept pathnames
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81750@lists.php.net to get a copy of this message
ID: 33663 User updated by: bengen+php at hilluzination dot de -Summary: The -b parameter to the FastCGI binary does accept pathnames Reported By: bengen+php at hilluzination dot de Status: Open Bug Type: CGI related Operating System: GNU/Linux PHP Version: 4.3.11 New Comment: Um. "not" added to title. Previous Comments: ------------------------------------------------------------------------ [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: -------------- bengen@ataraxia:~$ php4-cgi -b /tmp/foo bind/listen: No such file or directory Couldn't create FastCGI listen socket on port /tmp/foo bengen@ataraxia:~$ echo $? 255 bengen@ataraxia:~$ ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33663&edit=1

« previous php.bugs (#81750) next »