Skip to content

Missing AF_UNIX support from 0.9.13 #498

Description

@Parakleta

This issue presents itself in x11vnc, but is caused by a deviation between this project and 0.9.13 of the original project.

Specifically, running x11vnc -display :0 -rfbport 0 -unixsock /tmp/sock launches without a problem, but every attempt to connect using a client is rejected with the following error:

check_access: denying empty host IP address string.
denying client:  does not match (null)

The relevant code is in rfbNewTCPOrUDPClient. Specifically, after

the following code appears instead:

    if(isUDP) {
      rfbLog(" accepted UDP client\n");
    } else {
      struct sockaddr_in addr;
      socklen_t addrlen = sizeof(addr);
      memset(&addr, 0, sizeof(addr));

      if (getpeername(sock, (struct sockaddr *)&addr, &addrlen) < 0) {
        cl->host = strdup("NON_SOCKET");
      } else if (addr.sin_family == AF_UNIX) {
        struct sockaddr_un uaddr;
        addrlen = sizeof(uaddr);
        memset(&uaddr, 0, sizeof(uaddr));
        if (getsockname(sock, (struct sockaddr *)&uaddr, &addrlen) < 0) {
          cl->host = strdup("NAMEFAIL_AF_UNIX");
        } else if (!strcmp(uaddr.sun_path, "")) {
          cl->host = strdup("UNNAMED_AF_UNIX");
        } else {
          cl->host = strdup(uaddr.sun_path);
        }
      } else if (addr.sin_family == AF_INET) {
        if (!rfbSetTcpNoDelay(sock)) {
          close(sock);
          return NULL;
        }
        cl->host = strdup(inet_ntoa(addr.sin_addr));
      } else {
        cl->host = strdup("UNKNOWN_AF");
      }

The specific feature difference of this code is that it always sets cl->host so some value (except in the case of isUDP, not sure what the path is supposed to be there?). This is important because the callback cl->screen->newClientHook(cl) later in this same method does the access check that fails as shown above.

Curiously there is a bit of code in the x11vnc project under check_unix_sock() which updates the value of cl->host but this occurs only after the check_access method has already failed, and I cannot see any historical version of this project where that would have ever worked.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions