Subject: Re: Addition to force open to open only regular files
To: None <>
From: Simon Burge <>
List: tech-kern
Date: 11/12/2000 21:14:16
Greywolf wrote:

> On 10 Nov 2000, Nathan J. Williams wrote:
> # > So here are patches which add a new open flag, O_REG_FILE, and add a test
> # > to the kernel after we've done the name lookup but before we've done the
> # > VOP_OPEN() to make sure we really got a regular file.
> # > 
> # > Thoughts?
> # 
> # ``Yuck''.
> Agreed.
> If you're concerned about the type of file you're opening, OPEN the thing
> and then fstat(fd) it.  If it's not the right type, act appropriately,
> whether that means looping on trying to open something (based on user
> input) or abort and bitch.

It's that act of opening and then closing a file that would, for
example, cause a tape drive to rewind or eject.  By then it's too
late - fstat() will only tell you that the tape device you just
opened will eject when you close the device.

> It is not (always) the responsibility of the OS to solve the programmer's
> security issues.

While I don't entirely like the idea of this patch, I can not see
any other (cleaner) way to deal with this particular issue.  For
this reason, I will support it's inclusion into NetBSD.

Simon Burge                            <>
NetBSD Sales, Support and Service: