Skip to content

libvncserver: restore AF_UNIX client hosts#715

Open
marcofortina wants to merge 1 commit into
LibVNC:masterfrom
marcofortina:fix/af-unix-client-host
Open

libvncserver: restore AF_UNIX client hosts#715
marcofortina wants to merge 1 commit into
LibVNC:masterfrom
marcofortina:fix/af-unix-client-host

Conversation

@marcofortina
Copy link
Copy Markdown
Contributor

@marcofortina marcofortina commented May 16, 2026

Summary

Restore AF_UNIX client host handling for server-side Unix socket connections.

When a client connects through a Unix domain socket, rfbNewTCPOrUDPClient() currently treats the accepted socket like a TCP socket. On IPv6-capable builds, getnameinfo() fails for AF_UNIX and cl->host becomes an empty string. This breaks consumers such as x11vnc that run access checks in newClientHook() before they can repair the host value themselves.

Changes

  • Check the result of getpeername() before using the address.
  • Detect AF_UNIX sockets on Unix builds and populate cl->host from getsockname().
  • Use stable fallback host strings for unnamed or failed AF_UNIX lookups.
  • Apply TCP_NODELAY only to TCP clients, not AF_UNIX clients.
  • Add a Unix-only regression test that verifies an AF_UNIX client reaches newClientHook() with a non-empty host string.

Validation

Tested with:

cmake -S . -B build-498-patch \
  -DWITH_EXAMPLES=OFF \
  -DWITH_TESTS=ON \
  -DWITH_OPENSSL=OFF \
  -DWITH_GNUTLS=OFF \
  -DWITH_GCRYPT=OFF \
  -DWITH_SDL=OFF \
  -DWITH_GTK=OFF \
  -DWITH_QT=OFF \
  -DWITH_FFMPEG=OFF \
  -DWITH_XCB=OFF \
  -DWITH_LIBSSHTUNNEL=OFF \
  -DWITH_SYSTEMD=OFF \
  -DCMAKE_BUILD_TYPE=Debug

cmake --build build-498-patch --parallel 1
ctest --test-dir build-498-patch --output-on-failure

Result:

100% tests passed, 0 tests failed out of 6

Notes

Closes #498.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing AF_UNIX support from 0.9.13

2 participants