feat(net): add SocketShortener for Unix socket sun_path limit#398
Merged
Conversation
Unix domain sockets have a sun_path limit of 104 bytes (macOS) / 108
bytes (Linux). Long BOXLITE_HOME paths can exceed this limit.
Add SocketShortener that creates a short symlink in /tmp (e.g.,
/tmp/bl_{short_id}) pointing to the real sockets directory. The kernel
resolves symlinks during VFS lookup AFTER the sun_path length check,
so the short path satisfies the buffer constraint while socket files
physically remain in ~/.boxlite/. This is the same pattern used by
Open vSwitch (shorten_name_via_symlink in socket-util-unix.c).
Includes 18 unit tests covering symlink creation, cleanup, stale
symlink removal, and kernel bind/connect-through-symlink validation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SocketShortenertype that creates short/tmp/bl_{id}symlinks to work around the Unix socketsun_pathlimit (104 bytes on macOS, 108 on Linux)sun_pathlength check — same pattern used by Open vSwitch (shorten_name_via_symlink())~/.boxlite/boxes/{id}/sockets/— symlink is just a short aliasSocketShortener::new()returnsNonewhen paths already fit — no symlink created unnecessarilycleanup_stale_symlinks()for dead symlink removal on runtime startupDropTest plan
cargo test -p boxlite --lib net::socket_path)cargo clippy -p boxlite --lib -- -D warnings)