Skip site navigation (1)Skip section navigation (2)
Date:      16 Jan 1997 11:19:12 -0800
From:      jdp@polstra.com (John Polstra)
To:        freebsd-hackers@freebsd.org
Subject:   Re: open () unlinked?
Message-ID:  <5bluvg$q4j@austin.polstra.com>
References:  <32DE6EAC.1A1B@vailsys.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <32DE6EAC.1A1B@vailsys.com>, Hal Snyder  <hal@vailsys.com> wrote:
> I was at Marcus Ranum's Usenix '97 tuturial on Coding for Hostile
> Environments, and the subject came up of creating temporary files
> securely.  Open-then-unlink leaves a window for someone to get at the
> file.
> 
> Has there been any discussion here of adding, e.g., an O_UNLINK flag to
> open (), that would effectively create an anonymous temp file?

It's hard to see what that would buy you that you can't already get by
the time honored method:

    fd = open(path, O_RDWR|O_CREAT|O_TRUNC|O_EXCL, 0);

The key is the last argument 0, the file mode.  A mode of 0 means that
nobody except root can open the file.

John
-- 
   John Polstra                                       jdp@polstra.com
   John D. Polstra & Co., Inc.                Seattle, Washington USA
   "Self-knowledge is always bad news."                 -- John Barth



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5bluvg$q4j>