Bug #16121 Updated: fsockopen can't handle unix sockets created in abstract namespace
ID: 16121 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Feedback +Status: Closed Bug Type: Sockets related Operating System: any PHP Version: 4.0.6 Assigned To: wez New Comment: The new streams architecture now supports this; you can try it out using a recent snap of CVS. It won't be in PHP 4.2, but if you are happy making the change you describe below to your local source, you should be sorted. I'm closing this; if you manage to test CVS and find it has a problem, re-open this report. Previous Comments: [2002-03-20 15:21:22] [EMAIL PROTECTED] Great, that you are going to integrate something like that. Yes, unfortunatly this feature appears to be linux-only :-/ ('ve read man pages and wrote test code on SunOS 5.8, IRIX 3, FreeBSD 4.3 and MacOS X 10.1). Nevertheless it's a cool feature since Linux removes abdoned Unix sockets of the abstract namespace automatically -- you don't have to take care about removing Unix sockets, don't need clever code to figure out weither a unix socket file belongs to a vital daemon or just is left over... [2002-03-17 07:34:53] [EMAIL PROTECTED] My man page for unix sockets says this: If sun_path starts with a zero byte it refers to the abstract namespace maintained by the Unix protocol module. The socket's address in this namespace is given by the rest of the bytes in sun_path. Note that names in the abstract namespace are not zero-terminated. I'll integrate something that can handle this into the new streams architecture; you might not be able to do this in the PHP 4.2, but the release after will have it. Do you know if this is linux-only or do other platforms support it? [2002-03-16 21:56:41] [EMAIL PROTECTED] fsockopen can't handle unix sockets created in abstract namespace (unix sockets with the associated pathname starting with '\0'; see UNIX(4) of the 'Linux Programmer's Manual' for details). This bug is 'caused since the implementation of fsockopen in PHP 4.0.6 uses strlcpy to copy from $hostname to unix_addr.sun_path without looking at the first byte of $hostname (fsock.c, line 240). One possible solution would be to change line 240 from strlcpy(unix_addr.sun_path, (*args[0])->value.str.val, sizeof(unix_addr.sun_path)); to pathofs = ((*args[0])->value.str.val[0] ? 0 : 1); strlcpy(unix_addr.sun_path + pathofs, (*args[0])->value.str.val + pathofs, sizeof(unix_addr.sun_path) - pathofs); where pathofs would be of type "size_t". Another solution avoiding the ugly '\0' byte would be to introduce separate scheme prefixes like "file:" and "abstract:" for UNIX domain sockets. Ciao, Mathias -- Edit this bug report at http://bugs.php.net/?id=16121&edit=1
Bug #16121 Updated: fsockopen can't handle unix sockets created in abstract namespace
ID: 16121 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Feedback Bug Type: Sockets related Operating System: any PHP Version: 4.0.6 Assigned To: wez New Comment: Great, that you are going to integrate something like that. Yes, unfortunatly this feature appears to be linux-only :-/ ('ve read man pages and wrote test code on SunOS 5.8, IRIX 3, FreeBSD 4.3 and MacOS X 10.1). Nevertheless it's a cool feature since Linux removes abdoned Unix sockets of the abstract namespace automatically -- you don't have to take care about removing Unix sockets, don't need clever code to figure out weither a unix socket file belongs to a vital daemon or just is left over... Previous Comments: [2002-03-17 07:34:53] [EMAIL PROTECTED] My man page for unix sockets says this: If sun_path starts with a zero byte it refers to the abstract namespace maintained by the Unix protocol module. The socket's address in this namespace is given by the rest of the bytes in sun_path. Note that names in the abstract namespace are not zero-terminated. I'll integrate something that can handle this into the new streams architecture; you might not be able to do this in the PHP 4.2, but the release after will have it. Do you know if this is linux-only or do other platforms support it? [2002-03-16 21:56:41] [EMAIL PROTECTED] fsockopen can't handle unix sockets created in abstract namespace (unix sockets with the associated pathname starting with '\0'; see UNIX(4) of the 'Linux Programmer's Manual' for details). This bug is 'caused since the implementation of fsockopen in PHP 4.0.6 uses strlcpy to copy from $hostname to unix_addr.sun_path without looking at the first byte of $hostname (fsock.c, line 240). One possible solution would be to change line 240 from strlcpy(unix_addr.sun_path, (*args[0])->value.str.val, sizeof(unix_addr.sun_path)); to pathofs = ((*args[0])->value.str.val[0] ? 0 : 1); strlcpy(unix_addr.sun_path + pathofs, (*args[0])->value.str.val + pathofs, sizeof(unix_addr.sun_path) - pathofs); where pathofs would be of type "size_t". Another solution avoiding the ugly '\0' byte would be to introduce separate scheme prefixes like "file:" and "abstract:" for UNIX domain sockets. Ciao, Mathias -- Edit this bug report at http://bugs.php.net/?id=16121&edit=1
Bug #16121 Updated: fsockopen can't handle unix sockets created in abstract namespace
ID: 16121 Updated by: [EMAIL PROTECTED] -Summary: fsockopen can't handle unix sockets created in abstract namespace Reported By: [EMAIL PROTECTED] -Status: Open +Status: Feedback Bug Type: Sockets related Operating System: any PHP Version: 4.0.6 -Assigned To: +Assigned To: wez New Comment: My man page for unix sockets says this: If sun_path starts with a zero byte it refers to the abstract namespace maintained by the Unix protocol module. The socket's address in this namespace is given by the rest of the bytes in sun_path. Note that names in the abstract namespace are not zero-terminated. I'll integrate something that can handle this into the new streams architecture; you might not be able to do this in the PHP 4.2, but the release after will have it. Do you know if this is linux-only or do other platforms support it? Previous Comments: [2002-03-16 21:56:41] [EMAIL PROTECTED] fsockopen can't handle unix sockets created in abstract namespace (unix sockets with the associated pathname starting with '\0'; see UNIX(4) of the 'Linux Programmer's Manual' for details). This bug is 'caused since the implementation of fsockopen in PHP 4.0.6 uses strlcpy to copy from $hostname to unix_addr.sun_path without looking at the first byte of $hostname (fsock.c, line 240). One possible solution would be to change line 240 from strlcpy(unix_addr.sun_path, (*args[0])->value.str.val, sizeof(unix_addr.sun_path)); to pathofs = ((*args[0])->value.str.val[0] ? 0 : 1); strlcpy(unix_addr.sun_path + pathofs, (*args[0])->value.str.val + pathofs, sizeof(unix_addr.sun_path) - pathofs); where pathofs would be of type "size_t". Another solution avoiding the ugly '\0' byte would be to introduce separate scheme prefixes like "file:" and "abstract:" for UNIX domain sockets. Ciao, Mathias -- Edit this bug report at http://bugs.php.net/?id=16121&edit=1