lkml.org 
[lkml]   [2000]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: permissions not honoured by /bin/pwd aka getcwd
Harald Kirsch wrote:
> Why is /bin/pwd (or getcwd) allowed to return an output in the following
> command sequence?
>
> % mkdir -p really/closed; cd really/closed; chmod 000 ..; /bin/pwd
> /home1_phys/kir/sunHome/tmp/really/closed

Because getcwd doesn't follow the paths backwards, it simply knows the
whole path. Same for `ls -l /proc/self/fd' and `ls -ld /proc/self/cwd'.

Maybe it should be changed. Do you have a situation where it matters?

Richard B. Johnson wrote:
> Because permissions don't prevent you from reading a directory.

Yes they do:

[jamie@thefinal jamie]$ mkdir fum
[jamie@thefinal jamie]$ > fum/a
[jamie@thefinal jamie]$ > fum/b
[jamie@thefinal jamie]$ ls fum
a b
[jamie@thefinal jamie]$ chmod 000 fum
[jamie@thefinal jamie]$ ls fum
ls: fum: Permission denied

To be more precise, read permission controls whether you can readdir(),
and execute permission controls whether you can lookup entries e.g. to
stat(), open(), readlink() or follow subdirectory etc.

So by disabling read but enabling execute, you can have directory
containing files that people can read or write, but which they can't
list to find out the file names.

As a special exception, root is not subject to permission restrictions
so perhaps that confused you.

have a nice day,
-- Jamie

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.125 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site