[olug] Odd results from /bin/sh (GNU bash) and the "test" command...

Dan Linder dan at linder.org
Fri Feb 26 00:37:57 UTC 2010


On Thu, Feb 25, 2010 at 12:39, Trent Melcher <trentm at q.com> wrote:
> I wonder if its your distro,  Im using rhel 5 and it works as designed a
> regular user test comes back as unreadable and root test comes back as
> readable.  Which is what I would expect.

Interesting, I had forgot that "root" has these special powers:
$ date > /tmp/notreadable
$ chomd a-rwx /tmp/notreadable
$ ls -al /tmp/notreadable
---------- 1 dan dan 13222 2010-02-25 18:30 /tmp/notreadable
$ if [ -r /tmp/notreadable ] ; then echo READABLE ; else echo NOT ; fi
NOT
$ cat /tmp/notreadable
cat: /tmp/notreadable: Permission denied

$ sudo -i
# if [ -r /tmp/notreadable ] ; then echo READABLE ; fi
READABLE
# cat /tmp/notreadable
Thu Feb 25 18:33:51 CST 2010

But when the file is in /sys, the results are consistent:
$ mount | grep sysfs
none on /sys type sysfs (rw,noexec,nosuid,nodev)

$ cat /sys/bus/pci/drivers_probe
cat: /sys/bus/pci/drivers_probe: Permission denied

$ sudo -i
# cat /sys/bus/pci/drivers_probe
cat: /sys/bus/pci/drivers_probe: Permission denied

I wonder if it is a sysfs problem...?

Dan

-- 
***************** ************* *********** ******* ***** *** **
"Quis custodiet ipsos custodes?"
    (Who can watch the watchmen?)
    -- from the Satires of Juvenal
"I do not fear computers, I fear the lack of them."
    -- Isaac Asimov (Author)
** *** ***** ******* *********** ************* *****************



More information about the OLUG mailing list