1

I recently installed Open MPI, and it's complaining

PMIx has detected a temporary directory name that results
in a path that is too long for the Unix domain socket:
Temp dir: /var/folders/**/*****************************/T/openmpi-sessions-501@host*******************************/*****

This question suggests setting TMPDIR to /tmp. Is that safe? Will it mess up other programs?

3

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[104] 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
/tmp/mpi-zUN9SQo6

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 tmux or 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.

  • @patrix that's going to proliferate random tmp directories for each invocation; all that is really necessary is a single unique directory safe from /tmp vulnerabilities. – thrig Jun 23 '17 at 16:37
  • /private/tmp gets pruned regularly. If I just want one fixed tmp location for a specific application I would probably just create /tmp/APPNAME_temp and use this. – nohillside Jun 23 '17 at 16:40
  • Feel free to roll back the edit if necessary. – nohillside Jun 23 '17 at 16:41
  • Just for the sake of generalization: The method is to create a new temporary tempdir, use that for mpi, and then when mpi is done TMPDIR is back to the old value? So if I want to use mpi4py I can change TMPDIR, do whatever, and then just close that terminal? – NoethersOneRing Jun 23 '17 at 18:05
  • 1
    You would set an appropriate alias in your shell configuration; the terminal would not need to be closed as the custom environment would only apply to the command with the alias. Learning the basics of e.g. bash may be beneficial if this all seems mysterious. – thrig Jun 23 '17 at 18:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .