mitogen icon indicating copy to clipboard operation
mitogen copied to clipboard

AF_UNIX path too long for long TMPFILE paths

Open schanzel opened this issue 4 years ago • 0 comments

When setting the $TMPDIR var to a rather long path, it might happen that the mitogen.unix listener crashes when trying to bind to a socket file under that path. This is because Linux defines a maximum length of 107 chars for socket paths (cf. https://linux.die.net/man/7/unix, this limit differs on other *nix systems). The socket file for the listener is created here using tempfile.mktemp, which places temp files under either, $TMPDIR, $TEMP, or $TMP, with some exceptions (cf. https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir).

Without further knowledge of the chosen tempdir, it is error-prone to try and just create a socket file there, as we might well overshoot the UNIX_PATH_MAX limit.

A fix could be to place the socket files under, e.g., /tmp, or /run (limiting the portability, of course). Are there any other ideas how to fix that or work around it, assuming that setting a shorter $TMPDIR is not an option?

ERROR! [mux  26414] 15:01:44.839905 E ansible_mitogen.process: worker_main() crashed
Traceback (most recent call last):
  File ".../python3.8/site-packages/ansible_mitogen/process.py", line 650, in start
    self.worker_main()
  File ".../python3.8/site-packages/ansible_mitogen/process.py", line 672, in worker_main
    self._setup_master()
  File ".../python3.8/site-packages/ansible_mitogen/process.py", line 710, in _setup_master
    self.listener = mitogen.unix.Listener.build_stream(
  File ".../python3.8/site-packages/mitogen/unix.py", line 109, in build_stream
    sock.bind(path)
OSError: AF_UNIX path too long
  • Which version of Ansible are you running? 2.8

  • Is your version of Ansible patched in any way? no

  • Are you running with any custom modules, or module_utils loaded? no

  • Have you tried the latest master version from Git? yes

  • Do you have some idea of what the underlying problem may be? relying on $TMPDIR for unix sockets can be problematic

  • Mention your host and target OS and versions any *nix OS

  • Mention your host and target Python versions 3.8, but should affect any

schanzel avatar Sep 08 '21 11:09 schanzel