all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Sven Joachim <svenjoac@gmx.de>
Subject: sh-tmp-file inserts unsafe code
Date: Sun, 09 Oct 2005 17:30:36 +0200	[thread overview]
Message-ID: <4349379C.60103@gmx.de> (raw)

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	other threads:[~2005-10-09 15:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-09 15:30 Sven Joachim [this message]
2005-10-10  4:14 ` sh-tmp-file inserts unsafe code Richard M. Stallman
2005-10-10  8:20   ` Sven Joachim
2005-10-10 10:06     ` Emanuele Giaquinta
2005-10-10 15:10       ` Reiner Steib
2005-10-10 23:47       ` Richard M. Stallman
2005-10-11 13:53   ` Sven Joachim
     [not found]     ` <74205160510110729i683ad538xa6bdc6b76f131532@mail.gmail.com>
2005-10-11 14:41       ` Sven Joachim
2005-10-11 16:56         ` Reiner Steib
2005-10-12 16:24           ` Richard M. Stallman
2005-10-11 22:43     ` Richard M. Stallman
2005-10-10 17:46 ` Kevin Rodgers
  -- strict thread matches above, loose matches on Subject: below --
2005-10-11 13:55 Sven Joachim
2005-10-12 16:19 Sven Joachim
2005-10-12 19:23 Sven Joachim
2005-10-13 17:26 ` Kevin Rodgers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4349379C.60103@gmx.de \
    --to=svenjoac@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.