I'm a little bit confused here, maybe one of you guys can spot what I'm missing. I have some files on an NFS filesystem, that is set to root_squash. The file is owned by my network id (dboger), while I'm logged in locally as dan:
dan@dbdb$ ls -l somefile.png -r-------- 1 dboger 3813 2008-06-05 16:46 somefile.png
I'm trying to figure out if a file is readable, so I do something like:
dan@dbdb$ perl -le 'print "lies" if -r shift' somefile.png dan@dbdb$
That is correct - the file is owned by a different UID, and is set to 0400. Now, I try the same thing as root:
dan@dbdb$ sudo perl -le 'print "lies" if -r shift' somefile.png lies dan@dbdb$ sudo file somefile.png couldn't open file somefile.png: regular file, no read permission
Is perl just assuming that if I'm root I can always read the file, even though the permissions say that's wrong? The perldoc page for -r says:
Also note that, for the superuser on the local filesystems, the "-r", "-R", "-w", and "-W" tests always return 1, and "-x" and "-X" return 1 if any execute bit is set in the mode. Scripts run by the superuser may thus need to do a stat() to determine the actual mode of the file, or temporarily set their effective uid to something else.
But surely NFS doesn't count as a local filesystem? What am I missing?

-- zigdon


In reply to -r broken on root_squash NFS? by zigdon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.