1.1.6 Bind Mount the /var/tmp directory to /tmp

Information

The /var/tmp directory is normally a standalone directory in the /var file system. Binding /var/tmp to /tmp establishes an unbreakable link to /tmp that cannot be removed (even by the root user). It also allows /var/tmp to inherit the same mount options that /tmp owns, allowing /var/tmp to be protected in the same /tmp is protected. It will also prevent /var from filling up with temporary files as the contents of /var/tmp will actually reside in the file system containing /tmp.

Rationale:

All programs that use /var/tmp and /tmp to read/write temporary files will always be written to the /tmp file system, preventing a user from running the /var file system out of space or trying to perform operations that have been blocked in the /tmp filesystem.

Solution

Run the following command

# mount --bind /tmp /var/tmp

Edit the /etc/fstab file to contain the following line:

/tmp /var/tmp none bind 0 0

See Also

https://workbench.cisecurity.org/files/3096