On Fri 09 Jan 2004 at 23:10:02 +0900, Eivind Eklund wrote:

> I see two problems with this:
> (1) There is no such thing as "readable world" in the permissions of
>     Unix; the closest I can think of is the combination of user, group
>     and other permissions.

World-readable _is_ a term applied very often in the UNIX world to the
a file readable by anyone. I think the term is commonly understood.

>     Note that these are grabbed in order;
>     the user that own it CAN NOT read a file with permissions -wxrwxrwx.
>     Using permissions rwx---rwx is a trick that sometimes is used to
>     make sure that a particular group cannot get at data.

Good point. I tend to think of 'world' as being synonymous with 'other',
but it's not, of course.

>     This is resolvable by renaming to readable_other? (which is the
>     correct Unix terminology - see
>     http://www.opengroup.org/onlinepubs/7908799/xbd/glossary.html#tag_004_000_107
>     for details).

I even wondered "Shall I use 'world' or 'other'?", but I decided that
'world' would be clearer to people. After all, we already have
readable_real, not readable_user, although that's a different case
again, as we need to distinguish between real and effective UIDs.

> (2) If renamed to readable_other?, this is tied very closely to the
>     ancient Unix permissions systems.  This isn't even correct for new
>     Unixes (ACLs are available), and definately not correct for Windows
>     et al.

Well, I coded it so that it would return false on Windows, but how do
you deal with the ACL issue without Ruby to link to yet more system
dependent libraries?

> Thinking a bit more about it while writing this, I wonder if the right
> thing to do wouldn't be to extend the API with four calls instead of
> two:
> 
> readable_world? - check for
> 	(perm & (S_IRUSR|S_IRGRP|S_IROTH)) == (S_IRUSR|S_IRGRP|S_IROTH)
> 	  (that's the same as)
> 	(perm & 0444) == 0444
> readable_other? - check for
> 	(perm & S_IROTH) == S_IROTH
> 	  (that's the same as)
> 	(perm & 0004) == 0004
> 
> writable_world? and writeable_other? do the same for the write flags.
> 
> Introducing both of them has a couple of advantages:
> 	- It make it obvious to people that there is a difference
> 	- It provide at one call with semantics that can be used on
> 	  different permission systems
> 	- It provide the functionality requested (which I agree would be
> 	  nice to have - I'd be annoyed if I discovered it was missing.)

I like the idea. Of course, then we should probably have readable_group?
and writable_group?, too.

Matz, do you like the idea or do you consider these methods unnecessary?

Ian
-- 
Ian Macdonald               | It is a hard matter, my fellow citizens, to
System Administrator        | argue with the belly, since it has no ears.
ian / caliban.org             | -- Marcus Porcius Cato 
http://www.caliban.org      |