bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mkstemp


From: Bruno Haible
Subject: Re: mkstemp
Date: Thu, 28 Apr 2011 00:37:49 +0200
User-agent: KMail/1.9.9

Eric Blake wrote:
> > +# On some hosts, mkstemp creates files with mode 0666, which is a security
> > +# problem.
> 
> Also, it was valid in POSIX 2001, but violates POSIX 2008.

What about mkstemps? Does it have the same problem as mkstemp?

The answer is fortunately "no". The platforms x symbols matrix shows that
mkstemps() is defined on MacOS X, FreeBSD, OpenBSD, Solaris 11, and Cygwin 1.7.

I tested it with this program:
===============================================================================
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h> /* needed on MacOS X and FreeBSD */
#include <sys/types.h>
#include <sys/stat.h>

int main ()
{
  char templ[] = "myXXXXXX.foo";
  int ret;
  umask (0);
  ret = mkstemps (templ, 4);
  printf ("ret = %d\n", ret);
  system ("ls -l my*.foo");
  system ("rm my*.foo");
  return 0;
}
===============================================================================

and the results on MacOS X 10.5, OpenBSD 4.4, FreeBSD 6.4, Solaris 11 2010-11,
Cygwin 1.7 all look like this:

$ ./a.out
ret = 3
-rw------- 1 bruno staff 0 Apr 27 23:54 myiD4tTI.foo

That is, the created file has permissions 600.

Bruno
-- 
In memoriam Marian Batko <http://pl.wikipedia.org/wiki/Marian_Batko>
<http://en.auschwitz.org.pl/m/index.php?Itemid=8&id=478&option=com_content&task=view>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]