There can be security flaws that result from the careless use of
/tmp; malicious local users may be able to delete arbitrary files or possibly even run arbitrary code under your user account, depending on how bad the
/tmp flaw is. A solution that remains within the
char sun_path limit on unix domain sockets (see
/usr/include/sys/un.h for the definition) is to create a temporary directory and use that for MPI:
$ mktemp -d /tmp/mpi-XXXXXXXX
which leaves 86 characters for the socket file to use (104 minus one for the trailing
NUL minus 17).
Depending on where and when you set
TMPDIR other programs could easily be messed up, notably
screen that then may not then be able to locate their control socket. If possible, scope the custom
TMPDIR setting as close to the MPI calls as possible, e.g. with a shell function or alias along the lines of
alias mpi4py='TMPDIR=$(mktemp -d /tmp/mpi-XXXXXXXX) mpi4py'
This would create a unique temporary directory for each invocation; the directories in
/tmp are pruned automatically. If a shared or more persistent directory is needed
/var/tmp is typically more suitable
$ mkdir /var/tmp/mympi
and be sure to confirm the directory did not already exist in the event a far too clever local attacker has already created that directory (unlikely, but this is why
mktemp -d was created). Then, in your shell profile the alias might look something like
alias mpi4py='TMPDIR=/var/tmp/mympi mpi4py'
This form is again more suitable if there is shared state necessary between different MPI command invocations.