6.19. Mktemp-1.5

The Mktemp package contains programs used to create secure temporary files in shell scripts.

6.19.1. Installation of Mktemp

Many scripts still use the deprecated tempfile program, which has functionality similar to mktemp. Patch Mktemp to include an tempfile shell script wrapper:

patch -Np1 -i ../mktemp-1.5-add_tempfile-3.patch

Mktemp can be built with compiler warnings:

sed 's/^CFLAGS =.*/& -Wall -Wformat-security \\\
    -Werror -Wfatal-errors/' -i.orig Makefile.in

Prepare Mktemp for compilation:

./configure --prefix=/usr --bindir=/bin \
    --with-libc --with-random=/dev/urandom

The meaning of the configure options:

--bindir=/bin

This causes the mktemp program to be installed to /bin, so it is available to other programs if /usr is missing or not mounted.

--with-random=/dev/urandom

This causes the mktemp program to use /dev/urandom as an entropy source when creating temporary files.

Compile the package:

make

This package does not come with a test suite.

Install the package:

make install

The tempfile script does not need to be installed to /bin. Instead it can be installed to /usr/bin:

install -m 0555 ./tempfile /usr/bin/tempfile

6.19.2. Contents of Mktemp

Installed programs: mktemp and tempfile

Short Descriptions

mktemp

Creates temporary files in a secure manner; it is used in scripts

tempfile

Creates temporary files in a less secure manner than mktemp; it is installed for backwards-compatibility