Subject: Re: funlink() for fun!
To: Ignatios Souvatzis <is@netbsd.org>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 07/15/2003 13:28:42
On Tue, 15 Jul 2003, Ignatios Souvatzis wrote:
> Hi,
>
> On Tue, Jul 15, 2003 at 12:40:57PM -0700, Bill Studenmund wrote:
> > On Tue, 15 Jul 2003 ww@styx.org wrote:
> >
> > > Not really -- file descriptors inherited from parent processes:
> > > shell redirections and such.
> >
> > Yes, but come on, how many programs really really are going to want to
> > unlink stdin or stdout? Close, yes, but unlink?
>
> Some 31ee7 hAx0r group will surely find a way to, err, make use of
> unlinking stdin/stdout, if they find a vulnerable networked program.
>
> Seriously: think of passing some open descriptors to plug-ins , then letting
> _them_ dispose of the file... although you could open, unlink, then call
> the plugin, if it doesn't need the filename.
Since you're passing the fd in, why can't you pass in the path?
I'm not saying it's unreasonable for a module to unlink descriptors. I'm
saying it is unlikely that they will need to unlink (as opposed to close)
ones for which it can't find/know the path.
I'd really expect that in something like this, you'd do the unlink in the
same code block that did the open. That way, if you have an error
unliking, you don't use "not-really anonymous" temporary files.
Take care,
Bill