Re: Midnight Commander /tmp race

Pavel Kankovsky (peak@kerberos.troja.mff.cuni.cz)
Tue, 17 Mar 1998 18:21:09 +0100

On Sun, 15 Mar 1998, Michal Zalewski wrote:

> Midnight Commander (I have version 4.1.8, RedHat 5.0) is launched using
> the following shell macro:
>
> mc=()
> {
> MC=/tmp/mc$$-"$RANDOM";
> /usr/bin/mc -P "$@" >"$MC";
> cd "`cat $MC`";
> rm "$MC";
> unset MC
> }
>
> Solution? Use mktemp: MC=`mktemp mc$$-XXXXXX` instead of $RANDOM :)))

Solution? Don't use any temporary file at all.

mc()
{
MC=`/usr/bin/mc -P "$@"`
[ -n "$MC" ] && cd $MC
unset MC
}

The function is from mcfn_install script. The alias in lib/mc.csh is
similar. But lib/mc.sh is the aformentioned lame one. It's absurd.

--Pavel Kankovsky aka Peak [ Boycott Microsoft -- http://www.vcnet.com/bms ]