emacs-devel
[Top][All Lists]
Advanced

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

sh-tmp-file inserts unsafe code


From: Sven Joachim
Subject: sh-tmp-file inserts unsafe code
Date: Sun, 09 Oct 2005 17:30:36 +0200
User-agent: Mozilla Thunderbird 1.0.7 (X11/20051001)

The command `sh-tmp-file' (bound to `C-c C-t' in shell-script-mode)
inserts code to setup temporary file handling based on the script's
name and its pid at runtime.  E.g., for foo.sh:

TMP=${TMPDIR:-/tmp}/foo.sh.$$
trap "rm $TMP* 2>/dev/null" 0

Or for foo.csh:

set tmp = /tmp/foo.csh.$$
onintr exit

Such handling of temporary files used to be common practice, but it is
_unsafe_, exposing the user of the script to symlink attacks.  This is
especially bad if the script is to be run by the superuser, but even
an ordinary user could suffer data loss.  I think Emacs should not
encourage such dangerous coding practice.

How about rewriting sh-tmp-file so that it uses mktemp(1) to create
the temporary file?






reply via email to

[Prev in Thread] Current Thread [Next in Thread]