Nicholas Clark wrote:
On Mon, Mar 03, 2008 at 02:19:23PM +0000, Smylers wrote:
demerphq writes:

It turned out the problem is that when the tests are root it seems to
be not possible to create a directory that is not writeable by root.
I think that can be reduced to: It isn't possible to create a directory
that is not writeable by root.  The whole point of root is that as the
super-user it can do anything!

Im not really sure how to tackle this better than simply skipping the
tests as root which is what the most recent release does.
That's plausible.  It could also temporarily drop privileges to be some
other user for running that test, but I don't know how you'd work out
which user to do it as.

My guess would be "nobody" if that user exists, else give up.

But I agree that skipping is better, because the tests run as non-root
already prove that the module's functionality worked. Adding a lot
of complex logic to the test to swap user when running as root would
actually make the test as much a test of the user ID swapping code,
and introduce code that isn't usually tested, and generally introduce
fragility and cause false positive failures.

FWIW I do this a lot:

        chmod 0444, 'some_file';

        SKIP: {
            skip("cannot write readonly files", 1) if -w 'some_file';

            ...
        }

The important thing is that I'm not checking if I'm root but directly checking if the necessary condition exists, in this case an unwritable file.

You could attempt to downgrade permissions, switching to "nobody" is as good a guess as anything else, but realize it might effect the ability to read files, access directories and load modules for the rest of the test. Not everyone sets o+rx.


--
3. Not allowed to threaten anyone with black magic.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/

Reply via email to