[patch] make sure all uses of mkstemp follow umask
Erik Hovland
erik at hovland.org
Fri Jul 21 18:33:11 UTC 2006
On Fri, Jul 21, 2006 at 08:34:47AM +0200, Tito wrote:
> On Friday 21 July 2006 00:27, Erik Hovland wrote:
> > Using mkstemp without setting the permission mask with umask potentially
> > harmful.
> >
> > Since there are several uses of mkstemp in busybox and none of them use
> > umask, I made a libbb/umaskmkstemp.c file. That file has a umask() then
> > mkstemp() call in it called umaskmkstemp(). Then I switched all of the
> > users of mkstemp to this call instead.
> >
> > E
> >
> Hi,
> would it not be better to reset the old mask after the mkstemp call?
>
> int umaskmkstemp(char *path)
> {
> mode_t old_mask = umask(S_IRWXO | S_IRWXG);
> int ret = mkstemp(path);
> umask(old_mask);
> return ret;
> }
>
>
> Just a thought.
Dang good idea. I will update my patch.
E
--
Erik Hovland
mail: erik AT hovland DOT org
web: http://hovland.org/
PGP/GPG public key available on request
More information about the busybox
mailing list