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

From: Date: Tue, 12 Jul 2005 16:05:21 +0000
Subject: #33663 [Opn->Bgs]: 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-81764@lists.php.net to get a copy of this message
 ID:               33663
 Updated by:       sniper@php.net
 Reported By:      bengen+php at hilluzination dot de
-Status:           Open
+Status:           Bogus
 Bug Type:         CGI related
 Operating System: GNU/Linux
 PHP Version:      4.3.11
 New Comment:

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


Previous Comments:
------------------------------------------------------------------------

[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:
--------------
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


Thread (4 messages)

« previous php.bugs (#81764) next »