Re: mkstemp always generates the same file if removed between invocations

2023-10-13 Thread Bruno Haible
nce is that on Linux the following small application > produces different temporary files at each invocation: > > #include > #include > #include > #include > > char tmpl[100]; > > int main() > { > strncpy(tmpl, "stXX", 8); > // crea

mkstemp always generates the same file if removed between invocations

2023-10-11 Thread Sterpu Mihai
#include #include #include char tmpl[100]; int main() { strncpy(tmpl, "stXX", 8); // create temp file int fd = mkstemp(tmpl); printf("%s\n", tmpl); //close and remove file immediately after close(fd); remove(tmpl); return 0; } while on Windows, when b

Re: mkstemp

2011-04-27 Thread Bruno Haible
Eric Blake wrote: > > + dies from a fatal signal such as SIGQUIT, SIGKILL, or SIGABRT, SIGSEGV, > > + SIGBUS, SIGILL, SIGFPE, */ > > The grammar is a bit off, though. Should the "or" be moved to the end, SIGQUIT, SIGKILL are signals forceful kill signals from outside the program, whereas SI

Re: mkstemp

2011-04-27 Thread Eric Blake
On 04/27/2011 04:37 PM, Bruno Haible wrote: > 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 i

Re: mkstemp

2011-04-27 Thread Bruno Haible
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&qu

Re: mkstemp

2011-04-27 Thread Eric Blake
On 04/27/2011 03:29 PM, Bruno Haible wrote: > Just "less likely"?! The code in module 'clean-temp' goes through all kinds of > hoops with signal handlers and 'volatile' variables to make _sure_ that the > temporary files are cleaned up. This has also been tested as part of the > 'msgfmt' program. >

Re: [PATCH] mkstemp: replace if system version uses wrong permissions

2011-04-27 Thread Bruno Haible
> 2011-04-27 Reuben Thomas > and Eric Blake > > + mkstemp: replace if system version uses wrong permissions > + * m4/mkstemp.m4 (gl_FUNC_MKSTEMP): Add test for non-owner > + read/write mode bits set in file created by mkstemp. > + * doc/posix-f

Re: mkstemp

2011-04-27 Thread Bruno Haible
Eric Blake wrote: > I also think doc/posix-functions/mkstemp.texi could > use a similar comment. I added that, and pushed the modified result. Thanks, but... "The gnulib module clean-temp can create temporary files that are less likely to be left behind on signals such as SIGINT." Just "le

Re: [PATCH] mkstemp: replace if system version uses wrong permissions

2011-04-27 Thread Eric Blake
On 04/27/2011 10:24 AM, Reuben Thomas wrote: > On 27 April 2011 16:33, Eric Blake wrote: >> >> Here's the final version I'd like to push. It's modified a bit from >> your version; are you okay with it still being in your name? > > Thanks very much for polishing and testing this patch; I don't mi

Re: [PATCH] mkstemp: replace if system version uses wrong permissions

2011-04-27 Thread Reuben Thomas
On 27 April 2011 16:33, Eric Blake wrote: > > Here's the final version I'd like to push.  It's modified a bit from > your version; are you okay with it still being in your name? Thanks very much for polishing and testing this patch; I don't mind if my name is still on it. -- http://rrt.sc3d.org

[PATCH] mkstemp: replace if system version uses wrong permissions

2011-04-27 Thread Eric Blake
From: Reuben Thomas * m4/mkstemp.m4 (gl_FUNC_MKSTEMP): Add test for non-owner read/write mode bits set in file created by mkstemp. * doc/posix-functions/mkstemp.texi (mkstemp): Document the fix. Signed-off-by: Eric Blake --- Here's the final version I'd like to push. It's modi

Re: mkstemp

2011-04-27 Thread Reuben Thomas
On 27 April 2011 15:17, Eric Blake wrote: > > Can you convince your mailer to send patches inline, or at least with > text/plain MIME type? I think my only options are to rename the patch file (which will change the mailer's diagnosed MIME type) or to manually paste the patch into the body of the

Re: mkstemp

2011-04-27 Thread Eric Blake
On 04/27/2011 07:52 AM, Reuben Thomas wrote: > On 27 April 2011 14:00, Eric Blake wrote: >> On 04/27/2011 04:05 AM, Reuben Thomas wrote: >>> On 27 April 2011 03:24, Bruno Haible wrote: >>>>> Does setting a 0600 umask (as glibc does) sound like a good thing

Re: mkstemp

2011-04-27 Thread Eric Blake
On 04/27/2011 07:32 AM, Reuben Thomas wrote: > On 27 April 2011 14:00, Eric Blake wrote: >> On 04/27/2011 04:05 AM, Reuben Thomas wrote: >> >>> However, this suggests that the gnulib documentation for mkstemp >>> should direct the programmer to clean-temp, so

Re: mkstemp

2011-04-27 Thread Reuben Thomas
On 27 April 2011 14:00, Eric Blake wrote: > On 04/27/2011 04:05 AM, Reuben Thomas wrote: >> On 27 April 2011 03:24, Bruno Haible wrote: >>>> Does setting a 0600 umask (as glibc does) sound like a good thing to >>>> add to the mkstemp-safer functions? > > S

Re: mkstemp

2011-04-27 Thread Reuben Thomas
On 27 April 2011 14:00, Eric Blake wrote: > On 04/27/2011 04:05 AM, Reuben Thomas wrote: > >> However, this suggests that the gnulib documentation for mkstemp >> should direct the programmer to clean-temp, something like: >> >> "If you are creating temporar

Re: mkstemp

2011-04-27 Thread Eric Blake
On 04/27/2011 04:05 AM, Reuben Thomas wrote: > On 27 April 2011 03:24, Bruno Haible wrote: >>> Does setting a 0600 umask (as glibc does) sound like a good thing to >>> add to the mkstemp-safer functions? Setting umask() is bad for other reasons - it is global state, and

Re: mkstemp

2011-04-27 Thread Reuben Thomas
On 27 April 2011 03:24, Bruno Haible wrote: >> Does setting a 0600 umask (as glibc does) sound like a good thing to >> add to the mkstemp-safer functions? > > The application can call chmod() on its own. Why push this > into mkstemp-safer? I'm not suggesting chmod (

Re: mkstemp

2011-04-26 Thread Bruno Haible
Reuben Thomas wrote: > From mkstemp(3): > >More generally, the POSIX specification of mkstemp() does not > say anything about file modes, >so the application should make sure its file mode creation mask > (see umask(2)) is set >appropriately before c

mkstemp

2011-04-26 Thread Reuben Thomas
>From mkstemp(3): More generally, the POSIX specification of mkstemp() does not say anything about file modes, so the application should make sure its file mode creation mask (see umask(2)) is set appropriately before calling mkstemp() (and mkostemp()). Does setting a 0

mkstemp on mingw

2010-04-03 Thread Bruno Haible
Similarly for the mkstemp function: I'm seeing this error: ../gllib/stdlib.h:600: error: `mkstemp' was not declared in this scope > Here it becomes necessary to distinguish the two cases, like we do for many > other functions. Likewise here. This fixes it. 2010-04-

Re: mkstemp and tempname -> LGPLv2+

2008-08-07 Thread Jim Meyering
Eric Blake <[EMAIL PROTECTED]> wrote: > According to Jim Meyering on 8/7/2008 3:28 AM: > | I've just relicensed mkstemp to LGPLv2+, > | and would like to do the same to its dependent module, tempname. > | This is really just a formality, since the code is from glibc, &g

Re: mkstemp and tempname -> LGPLv2+

2008-08-07 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Jim Meyering on 8/7/2008 3:28 AM: | I've just relicensed mkstemp to LGPLv2+, | and would like to do the same to its dependent module, tempname. | This is really just a formality, since the code is from glibc, | | Ok with you, Eric?

mkstemp and tempname -> LGPLv2+

2008-08-07 Thread Jim Meyering
I've just relicensed mkstemp to LGPLv2+, and would like to do the same to its dependent module, tempname. This is really just a formality, since the code is from glibc, Ok with you, Eric? >From eb8c6a45f2a176b5b070f56ce7d5c87c9235ba84 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[EMAI

Re: mkstemp declaration fix

2007-03-20 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Bruce Korb on 3/20/2007 10:00 AM: >> The reason is that mkstemp is declared in , not , on >> this platform. But for POSIX compatibility, only gnulib's should >> be sufficient to declare the function. I'

Re: mkstemp declaration fix

2007-03-20 Thread Bruce Korb
Bruno Haible wrote: > Hello, > > On MacOS X 10.3, one gets this warning: > > mkstemp-safer.c:34: warning: implicit declaration of function `mkstemp' > > The reason is that mkstemp is declared in , not , on > this platform. But for POSIX compatibility, only gnulib

mkstemp declaration fix

2007-03-19 Thread Bruno Haible
Hello, On MacOS X 10.3, one gets this warning: mkstemp-safer.c:34: warning: implicit declaration of function `mkstemp' The reason is that mkstemp is declared in , not , on this platform. But for POSIX compatibility, only gnulib's should be sufficient to declare the function. I'

mkstemp.h needs a mention in modules/mkstemp

2006-09-20 Thread Paul Eggert
I intsalled this: 2006-09-20 Paul Eggert <[EMAIL PROTECTED]> * modules/mkstemp (Files): Add mkstemp.h. --- modules/mkstemp 20 Sep 2006 18:48:29 - 1.10 +++ modules/mkstemp 20 Sep 2006 22:32:08 - @@ -2,6 +2,7 @@ Description: mkstemp() function: create a p

mkstemp-safer followup

2006-09-20 Thread Paul Eggert
I also installed this further change, which shouldn't hurt either. That old HAVE_MKSTEMP code was bogus anyway, since it should have been HAVE_DECL_MKSTEMP. 2006-09-20 Paul Eggert <[EMAIL PROTECTED]> * mkstemp-safer.c: Include "mkstemp.h" instead of . (mk

Re: mkstemp-safer.c must include

2005-11-14 Thread Jim Meyering
Jim Meyering <[EMAIL PROTECTED]> wrote: > The problem is that on systems for which m4/mkstemp.c > would normally make an application use the replacement > function, an application calling mkstemp_safer would end up > using the buggy version, because mkstemp-safer.c didn

mkstemp-safer.c must include

2005-11-13 Thread Jim Meyering
I found this bug by inspection. The problem is that on systems for which m4/mkstemp.c would normally make an application use the replacement function, an application calling mkstemp_safer would end up using the buggy version, because mkstemp-safer.c didn't include (for the mkstemp -> mks