Alternatively, you can create some name containing well random letters. You can read some random bytes from /dev/random (or /dev/urandom , read random (4) ), for example. seed PRNG (e.g. random (3) seeded srandom ) and / or mix PID and time, etc.
And since the named fifo (7) are files, you must use a permission system (and / or ACL ). In particular, you can create a Linux user team to run all your processes and restrict FIFOs to read only, etc.
Of course, and in all cases, you need to “store” or “transfer” these FIFO names securely.
If you run your programs in some bash script, you might want your fifo names to use mktemp (1) as:
fifoname=$(mktemp -u -t yourprog_XXXXXX).fifo-$RANDOM-$$ mkfifo -m 0600 $fifoname
(possibly in some cycle). I think this would be safe enough if the script runs on a dedicated user (and then pass $fifoname in some channel or file, and not as a program argument)
The recent renameat2 (2) syscall may be useful (atomicity RENAME_EXCHANGE ).
By the way, you may need SElinux. Remember that open file descriptors - and which include your fifos - are available as symbolic links in proc (5) !
PS. it all depends on how paranoid you are. A well-established Linux system can be quite safe ...
source share