Hi,
According to a 'php -h' output of php-cgi 5.1.2 the FastCGI can be used
only by TCP/IP:
-b <address:port>|<port> Bind Path for external FASTCGI Server mode
But according to the code FastCGI could also be used by UNIX sockets.
According to the code if the "-b <address:port>" option is used and the
port number is illegal or omitted then all the "address:port" string
assumed as a UNIX socket name. That means that the UNIX socket should
allways include a ":" in its filename. My patch eliminate this limitation.
After applying it one should use "-b socket:" for UNIX sockets and
"-b address:port" or "-b port" for TCP/IP. And if the port number is
illegal, an error message is printed. If the "-b socket:" format is used
the ":" is not added to the UNIX socket filename.
What do you think about following patch?
--- sapi/cgi/libfcgi/os_unix.c.orig Sun Dec 7 14:59:54 2003
+++ sapi/cgi/libfcgi/os_unix.c Mon Mar 20 09:28:28 2006
@@ -299,13 +299,15 @@
char host[MAXPATHLEN];
strlcpy(host, bindPath, MAXPATHLEN-1);
- if((tp = strchr(host, ':')) != 0) {
+ if((tp = strrchr(host, ':')) != 0) {
*tp++ = 0;
- if((port = atoi(tp)) == 0) {
- *--tp = ':';
- } else {
+ if (*tp != '\0') {
+ if((port = atoi(tp)) == 0) {
+ fprintf(stderr, "%s is illegal port number!\n", tp);
+ return -1;
+ }
tcp = TRUE;
- }
+ }
}
if(tcp) {
if (!*host || !strcmp(host,"*")) {
@@ -357,7 +359,7 @@
servLen = sizeof(sa.inetVariant);
} else {
unlink(bindPath);
- if(OS_BuildSockAddrUn(bindPath, &sa.unixVariant, &servLen)) {
+ if(OS_BuildSockAddrUn(host, &sa.unixVariant, &servLen)) {
fprintf(stderr, "Listening socket's path name is too long.\n");
return -1;
}
This patch changes an OS_CreateLocalIpcFd() function. The same change
of OS_FcgiConnect() should probably be done as well. I didn't because
the OS_FcgiConnect() isn't used anywhere by php.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php