Subject: Re: standards/19209: test(1)'s -r, -w, and -x don't match POSIX for root (or 4.4BSD, or even V7)
To: NetBSD Bugs and PR posting List <netbsd-bugs@NetBSD.ORG>
From: David Laight <david@l8s.co.uk>
List: netbsd-bugs
Date: 12/01/2002 20:02:11
On Sat, Nov 30, 2002 at 04:34:26PM -0500, Greg A. Woods wrote:
> [ On Saturday, November 30, 2002 at 10:17:20 (+0000), David Laight wrote: ]
> > Subject: Re: standards/19209: test(1)'s -r, -w, and -x don't match POSIX for root (or 4.4BSD, or even V7)
> >
> > > > + 	euid = geteuid();
> > > > + 	if (euid == 0)
> > > 
> > > I don't think userspace ought to be checking for 'appropriate
> > > privileges' by checking uid == 0.  It is currently true for
> > > netbsd but isn't portably true.
> > 
> > It isn't true for NFS!
> 
> What does NFS have to do with the privileges of a program running on a
> given host?  Just because you're "root" on some host doesn't mean you'll
> be "root" on some other NFS server.

My point exactly! So the test program cannot use the euid to determine
whether you have 'appropriate privileges' to access the file in question.
Your version of test will incorrectly say that root has permission
when in fact it does not.

> Except for a few very special cases
> the effect of root accesses to an NFS volume that's exported with client
> UID==0 mapped to UID=-2 (or whatever) is effectively the same, from
> 'test's point of view, as it is for filesystems mounted read-only.  Test
> does not, and should not, care about the filesystem mount options here.

The posix spec explicitly states that a test -w should fail if
the filesystem is mounted readonly.


	David

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