[PATCH] xmkstemp: safe mkstemp (-65 bytes)

walter harms wharms at bfs.de
Fri Oct 22 15:29:11 UTC 2010



Alexander Shishkin schrieb:
> On Fri, Oct 22, 2010 at 01:44:08 +0200, Denys Vlasenko wrote:
>> On Fri, Oct 22, 2010 at 1:35 PM, walter harms <wharms at bfs.de> wrote:
>>> from the man page:
>>>
>>>       More generally, the POSIX specification of mkstemp() does not say  any-
>>>       thing  about  file  modes, so the application should make sure its file
>>>       mode creation mask (see umask(2)) is set appropriately  before  calling
>>>       mkstemp()
>>>
>>> perhaps a umask(0077) is missing?
>> But how mkstemp() knows what would be an "appropriate" umask?
>> Only caller knows that.
> 
> Yes, ok, only some of the callers need that. Perhaps I should do that on a
> case-by-case basis. Like, diff or lpr create the tempfile for internal private
> usage and there it makes sense to set the umask.
> 
> Do you think it makes sense to extend the xmkstemp() to take flags for that, or
> make it another function or do that in place in those applets that need it?
> 

There is a GNU_SOURCE extension "int mkostemp (char *template, int flags);"
perhaps that is what you are looking at ?

re,
 wh


More information about the busybox mailing list