From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Cc: | Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: About pg_upgrade |
Date: | 2002-01-15 06:15:23 |
Message-ID: | 200201150615.g0F6FNC17784@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> > Still not sure about those temp files. People like to see a possible
> > exploit in every temp file.
>
> Well, yes, if you get the pid, you can create symlink files in /tmp and
> overwrite things. How do I handle this properly, probably a directory
> in /tmp that I create but I have to set my umask first -- is that a
> plan?
Forget what I said, you don't need to change the umask, just do:
trap "rm -rf /tmp/$$" 0 1 2 3 15
mkdir /tmp/$$ || exit 1
and you call all your temp files /tmp/$$/XXX, right? Once you create
the directory, you own it and no one else can write into there.
I just did a Google search and no one came up with this idea, though I
believe X11 uses /tmp directories for this exact reason, right?
I finally found one mention of it: Seems Suse uses it, but they did
'mkdir -p' which doesn't return an error if it fails so it was a
security problem itself:
I just looked in /usr/bin on BSD/OS and found a whole bunch that do the
insecure /tmp/$$ trick I currently do in pg_upgrade:
#$ file `grep -l '\$\$' *` | grep shell
cvsbug: Bourne shell script text
igawk: Bourne shell script text
lorder: Bourne shell script text
mkdep: Bourne shell script text
pppattach: Korn shell script text
rcsfreeze: Bourne shell script text
sendbug: Bourne shell script text
uupick: Bourne shell script text
For example, cvsbug does:
[ -z "$TMPDIR" ] && TMPDIR=/tmp
TEMP=$TMPDIR/p$$
BAD=$TMPDIR/pbad$$
REF=$TMPDIR/pf$$
Bet everyone has that one on their system. :-)
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
From | Date | Subject | |
---|---|---|---|
Next Message | Barry Lind | 2002-01-15 06:35:29 | problem with notify/listen |
Previous Message | Brent Verner | 2002-01-15 06:10:57 | Re: Problem reloading regression database |