Boost logo

Boost :

From: Ross Smith (r-smith_at_[hidden])
Date: 2002-03-27 01:29:24


Jan Langer wrote:
>
> On Wed, 27 Mar 2002, Ross Smith wrote:
> >> - i would replace the readonly-flag by writable and readable (and also
> >> is_readonly by is_readable and is_writeable). this is much clearer.
> >
> >I would too if it was practical, but either way it's too hard to
> >implement on Unix. (is_readable() would be easy, just try to open it,
> >but is_writable() is next to impossible.)
>
> why? you can read the file permissions and owner informations with stat,
> the gid and uid with getuid and getgid and then compare them.

One big complication here is supplementary groups. A user or a process
can be a member of more than one group; the details vary from system to
system.

Then there's the matter of execute permission on the parent directory;
of whether x permission on all the directories up the path is checked
(it's supposed to be, but some systems allow you to bypass it); of the
special privileges of root processes; of effective vs real user/group
ids; and probably other points I'm forgetting.

It's not impossible. But it's a lot of overhead, and there's no portable
(between unices) way to do parts of it.

-- 
Ross Smith ...................................... Auckland, New Zealand
r-smith_at_[hidden] ....................................................
  "We need a new cosmology. New gods. New sacraments. Another drink."
                                                       -- Patti Smith

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk