tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: O_NOACCESS?



On Sat, Feb 11, 2012 at 02:04:23AM -0500, Mouse wrote:
> I find myself wanting something I'm tentatively calling O_NOACCESS,
> which is basically "open for neither read nor write".  (I want this
> mostly so I can open a --x directory for fchdir() purposes.)
> 
> Looking at sys_open(), I see that one of the first checks it does is
> 
>         if ((flags & (FREAD | FWRITE)) == 0)
>                 return (EINVAL);

Not the least of your problems is that the user specifies one of
O_RDONLY, O_WRONLY or O_RDWR - which are 0, 1 and 2.
Makes it a little difficult to request 'no access'.

But I agree, an open(".", ???) in particular should work even when
you only have 'x' permissions so that you can fchdir() back later.

Possibly even open(".", O_RDONLY) shouls succeed - but not let
you perform any operations except fchdir() (and maybe openat()).

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index