Bug 13562 - libxcb-1.1: xcb_auth.c/xcb_util.c problem fix (Solaris2.6)
Summary: libxcb-1.1: xcb_auth.c/xcb_util.c problem fix (Solaris2.6)
Status: RESOLVED WONTFIX
Alias: None
Product: XCB
Classification: Unclassified
Component: Library (show other bugs)
Version: 1.0
Hardware: SPARC Solaris
: medium normal
Assignee: Jamey Sharp
QA Contact: xcb mailing list dummy
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-07 10:12 UTC by acni
Modified: 2019-02-16 12:58 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description acni 2007-12-07 10:12:34 UTC
Building libxcb-1.1 on Solaris2.6 also fails because on this
old system, the newer getaddrinfo() / freeaddrinfo() are not
available and AF_INET6 is not defined. (You may ask yourself
why to bother with such an old system. Well, among others, some
old hardware drivers are not available for newer OS versions).
A solution seems simple enough to be worth considering: On systems
which don't have getaddrinfo(), use the older gethostbyname()
and exclude the AF_INET6 containing blocks (since not available
on these systems, anyway). Maybe '#ifdef AF_INET6' could be used
for both conditional changes without any change in 'configure'
or else configure could work out if getaddrinfo() is available
(#define HAS_GETADDRINFO)...
When I applied the following changes to xcb_auth.c and xcb_util.c
then compilation worked, but maybe someone with more experience
in network programming should check and test:

xcb_auth.c, line 95, switch construct in function get_authptr():
conditionally exclude the whole 'case AF_INET6:' block (10 lines)
with an #ifdef AF_INET6 / #endif pair.

xcb_util.c, line 201 , function _xcb_open_tcp():
conditionally replace the whole function, using some construct
like #ifdef HAS_GETADDRINFO (or maybe just #ifdef AF_INET6 ?)
/ #else / #endif, with some alternative function similar to:
...
#else
/* //### for older systems, for example Solaris2.6,
   //### rewrite to use gethostbyname() instead of getaddrinfo() which
   //### was not yet available on these old systems.
*/
static int _xcb_open_tcp(char *host, char *protocol, const unsigned short port)
{
    int fd = -1;
    struct hostent *hostent_results;
    struct sockaddr sock_addr;
    char **pAddr; 
    char *bracket;

    if (protocol && strcmp("tcp",protocol))
        return -1;

    /* DO NOT allow IPv6 addresses enclosed in brackets. */
    if(host[0] == '[' && (bracket = strrchr(host, ']')) && bracket[1] == '\0')
        return -1;

    if ( NULL == (hostent_results = gethostbyname(host)) )
        return -1;

    for(pAddr = hostent_results->h_addr_list; *pAddr; pAddr++)
    {
        fd = socket(AF_INET, SOCK_STREAM, 0);
        sock_addr.sa_family = AF_INET;
        memcpy(sock_addr.sa_data, *pAddr, hostent_results->h_length); 
        if(fd >= 0 && connect(fd, &sock_addr, hostent_results->h_length) >= 0)
            break;
        fd = -1;
    }
    return fd;
}
#endif

[compiles / allows libxcb to be built - but function is not tested!]
Comment 1 Jamey Sharp 2009-10-09 08:38:21 UTC
Changes for systems without support for IPv6 have gone in since you filed this bug, but a fallback for systems without getaddrinfo hasn't. I'd like to see a patch using autoconf to check for getaddrinfo. Anybody?
Comment 2 Daniel Stone 2019-02-16 12:58:15 UTC
Given that we didn't get a patch back then, I don't think a full ten years later we're likely to get patches in from Solaris 2.6 users.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.