2

The application written in golang and is ran within Debian bookworm based docker container fails to listen for the unix socket with the error message listen unix [socket-path]: bind: invalid argument

And it looks the issue is reproduced only if the socket path is big enough (something bigger than about 100 chars). And it is not clear does it matter the full socket length or the base name it self as trying different combination looks to fail at different critical length values.

The name being used for the socket is a regular base64 string (without = marks) on some seed data

E.g it works well for

/var/lib/R9D5kgn3JfYgcpo3RX2nSzkQ2BIXXNSnJHpP4gR9D5kgn3JfYgcpo3RX2nSzkQ2BIXXNSnJHpP4g.sock

yet fails on

listen unix /var/lib/R9D5kgn3JfYgcpo3RX2nSzkQ2BIXXNSnJHpP4gR9D5kgn3JfYgcpo3RX2nSzkQ2BIXXNSnJHpP4gR9D5kgn3JfYgcpo3RX2nSzkQ2BIXXNSnJHpP4g.sock: bind: invalid argument

So

  • who (what level (golang, linux, docker on a Mac vm)) actually runs the restriction.
  • what are exact criterions/limits
  • could the limits be extended or the restriction be suppressed at all
4
  • What is the actual text you are using for the socket? Commented May 31 at 11:16
  • @OldBoy do you mean the name it self. It is just a base64 based string. I've updated the question. Commented May 31 at 11:33
  • 1
    Please update your question with (as already requested) the actual text you are using for the socket. Commented May 31 at 11:55
  • @OldBoy Please I've added the real case examples. Commented May 31 at 12:28

1 Answer 1

4

The maximum size for the name of a UNIX domain socket is restricted by the definition in the sockaddr_un structure. On Linux it is 108, which fits your observation of "something bigger than about 100 chars". From man unix:

A UNIX domain socket address is represented in the following
structure:

    struct sockaddr_un {
        sa_family_t sun_family;               /* AF_UNIX */
        char        sun_path[108];            /* Pathname */
    };

The sun_family field always contains AF_UNIX.  On Linux, sun_path
is 108 bytes in size ...
Sign up to request clarification or add additional context in comments.

1 Comment

Ah. yes it was really 109 char starting to fail from. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.