issue #754: support MITOGEN_UNIX_DIR environment variable

dmw
David Wilson 4 years ago
parent 72e3b69daf
commit 2207bea6eb

@ -627,7 +627,10 @@ class MuxProcess(object):
#: MuxProcess CPU index. #: MuxProcess CPU index.
self.index = index self.index = index
#: Individual path of this process. #: Individual path of this process.
self.path = mitogen.unix.make_socket_path() self.path = mitogen.unix.make_socket_path(
# issue #754: overlong temp paths may easily overflow sockaddr_un
dir=os.environ.get('MITOGEN_UNIX_DIR'),
)
def start(self): def start(self):
self.pid = os.fork() self.pid = os.fork()

@ -515,6 +515,18 @@ In summary, for each task Ansible may create one or more of:
* ``$TMPDIR/ansible_<modname>_payload_.../`` owned by the become user, * ``$TMPDIR/ansible_<modname>_payload_.../`` owned by the become user,
* ``$TMPDIR/ansible-module-tmp-.../`` owned by the become user. * ``$TMPDIR/ansible-module-tmp-.../`` owned by the become user.
Temporary Files (Controller)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To create UNIX sockets used for inter-process communication on the Ansible
controller host, Mitogen normally uses a temporary directory selected
by the :mod:`tempfile` module, however is possible the selected directory
cannot be used as its name its path exceeds the system-defined 108 byte limit
on UNIX socket paths.
In this case, the ``MITOGEN_UNIX_DIR`` environment variable may be used to
define an alternative directory.
Mitogen for Ansible Mitogen for Ansible
^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^

@ -79,8 +79,12 @@ def is_path_dead(path):
return False return False
def make_socket_path(): def make_socket_path(dir=None):
return tempfile.mktemp(prefix='mitogen_unix_', suffix='.sock') return tempfile.mktemp(
prefix='mitogen_unix_',
suffix='.sock',
dir=dir,
)
class ListenerStream(mitogen.core.Stream): class ListenerStream(mitogen.core.Stream):

Loading…
Cancel
Save