From: "Brian O'Mahoney" <omb@khandalf.com>
To: Paul Jackson <pj@sgi.com>
Cc: Dave Jones <davej@redhat.com>,
pasky@ucw.cz, git@vger.kernel.org, mj@ucw.cz
Subject: Re: fix mktemp (remove mktemp ;)
Date: Sun, 17 Apr 2005 04:38:45 +0200 [thread overview]
Message-ID: <4261CC35.4070108@khandalf.com> (raw)
In-Reply-To: <20050416174409.59f94c26.pj@sgi.com>
No, you have to:
(a) create a unique, pid specific file name /var/tmp/myapp.$$.xyzzy
(b) create it in O_EXCL mode, so you wont smash another's held lock
(b-1) It worked, OK
(b-2) open failed, try ...xyzzz
repeat until (b-1)
There are thousands of examples of how to do this with bash.
Paul Jackson wrote:
> Dave wrote:
>
>>mktemp is being used here to provide randomness in the filename,
>>not just a uniqueness.
>
>
> Ok - useful point.
>
> How about:
>
> t=${TMPDIR:-/usr/tmp}/gitdiff.$$.$RANDOM
>
>
>>all an attacker has to do is create 65535 symlinks in /usr/tmp
the point of the xyzzy seed is to make creating all possible files
in-feasable.
>
>
> And how about if I removed the tmp files at the top:
>
> t=${TMPDIR:-/usr/tmp}/gitdiff.$$.$RANDOM
> trap 'rm -fr $t.?; trap 0; exit 0' 0 1 2 3 15
> rm -fr $t.?
>
> ... rest of script ...
>
> How close does that come to providing the same level of safety, while
> remaining portable over a wider range of systems, and not requiring that
> a separate command be forked?
>
>
>>I'd suggest fixing your distributions ...
>
>
> It's not just my distro; it's the distros of all git users.
>
> If apps can avoid depending on inessential details of their
> environment, that's friendlier to all concerned.
>
> And actually my distro is fine - it's just that I am running an old
> version of it on one of my systems. Newer versions of the mktemp -t
> option.
>
--
mit freundlichen Grüßen, Brian.
Dr. Brian O'Mahoney
Mobile +41 (0)79 334 8035 Email: omb@bluewin.ch
Bleicherstrasse 25, CH-8953 Dietikon, Switzerland
PGP Key fingerprint = 33 41 A2 DE 35 7C CE 5D F5 14 39 C9 6D 38 56 D5
next prev parent reply other threads:[~2005-04-17 2:35 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-16 23:27 [PATCH] fix mktemp (remove mktemp ;) Paul Jackson
2005-04-16 23:27 ` [PATCH] missing mkdir -p flag in gitdiff-do Paul Jackson
2005-04-16 23:28 ` [PATCH] optimize gitdiff-do script Paul Jackson
2005-04-16 23:43 ` Petr Baudis
2005-04-17 0:10 ` Paul Jackson
2005-04-18 15:23 ` Paul Jackson
2005-04-18 18:30 ` Petr Baudis
2005-04-18 19:17 ` Paul Jackson
2005-05-10 2:56 ` Paul Jackson
2005-04-16 23:36 ` [PATCH] fix mktemp (remove mktemp ;) Jan-Benedict Glaw
2005-04-16 23:46 ` Paul Jackson
2005-04-16 23:37 ` Petr Baudis
2005-04-17 0:02 ` Paul Jackson
2005-04-17 0:33 ` Dave Jones
2005-04-17 0:44 ` Paul Jackson
2005-04-17 0:57 ` Dave Jones
2005-04-17 1:03 ` David Lang
2005-04-17 1:15 ` Paul Jackson
2005-04-17 2:38 ` Brian O'Mahoney [this message]
2005-04-17 2:46 ` Paul Jackson
2005-04-17 0:51 ` Erik van Konijnenburg
2005-04-17 1:18 ` Paul Jackson
2005-04-18 3:01 ` Herbert Xu
2005-04-18 4:47 ` Paul Jackson
2005-04-18 12:12 ` Florian Weimer
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=4261CC35.4070108@khandalf.com \
--to=omb@khandalf.com \
--cc=davej@redhat.com \
--cc=git@vger.kernel.org \
--cc=mj@ucw.cz \
--cc=omb@bluewin.ch \
--cc=pasky@ucw.cz \
--cc=pj@sgi.com \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).