[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Temporary file policy



As Topi has filed another slew of bugs regarding careless use of
temporary files, I decided I had better make the new temporary file
policy better known.

A new command, tempfile(1), was added to debianutils 1.6.  tempfile
creates a temporary file in a safe manner.  It uses tempnam(3) and
allows you to specify the directory, prefix, and mode.  For example,
you can use it like this:

set -e
tf=$(tempfile -m 600)
echo "super secret something" > $tf
mv $tf /etc/whatever

Using tempfile is better than doing something like `tf=/etc/temp$$'
above - the file is guaranteed to be unique, your shell script will
use TMPDIR if it's set, permissions are easier to specify, it will
work in directories which are writable by a group, etc.


Guy


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-announce-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: