Skip to content

linux: keep the whole Unix socket path from /proc/net/unix - #385

Merged
jiegec merged 1 commit into
lsof-org:masterfrom
Ar-maan05:unix-path-with-space
Nov 10, 2026
Merged

jiegec merged 1 commit into
lsof-org:masterfrom
Ar-maan05:unix-path-with-space

Conversation

@Ar-maan05

@Ar-maan05 Ar-maan05 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

unix socket paths with a space or a : get cut off on linux:

socket bound to "my sock"
before: my type=STREAM (LISTEN)
after:  my sock type=STREAM (LISTEN)

get_unix() splits the /proc/net/unix line on blanks and :, so the path is only the first word. the kernel prints the path last after one blank, so the fix takes it from the line as is (blanks, TABs, : all kept) and only splits the feilds before it.

added case-20-ux-socket-path-space.bash using a path with blanks, a TAB and a :. it fails before and passes after, make check is clean except LTlock, which fails on my machine without the change too.

@jiegec

jiegec commented Nov 9, 2026

Copy link
Copy Markdown
Member

When testing this, I found that TABs may appear in unix socket path, which will be truncated as well. Maybe we need a better way to handle the fragile text parsing.

get_unix() split each line on blanks, TABs and ':' and used only the 8th field as the path, so a socket bound to "/tmp/my sock" was shown as "/tmp/my", and one with a ':' or a TAB in its name was cut there. The kernel prints the path last, after a single blank, up to the newline, so take it from the line as is and split only the fields before it.
@Ar-maan05
Ar-maan05 force-pushed the unix-path-with-space branch from 2e9c5dd to b94c50f Compare November 9, 2026 14:27
@Ar-maan05

Copy link
Copy Markdown
Contributor Author

good catch, thanks! get_fields() always treats TAB as a seperator so the eb[] route couldnt cover it. the kernel prints the path last after a single space, so i changed it to just take everything after the 7th field up to the newline, and only split the fields before that. tabs, double spaces and ':' all come through now, and the test uses a path with all three.

@jiegec
jiegec merged commit b0f58ea into lsof-org:master Nov 10, 2026
17 checks passed
@Ar-maan05
Ar-maan05 deleted the unix-path-with-space branch November 10, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants