public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* can i modify ls
@ 2004-02-27 21:03 Gautam Pagedar
  2004-02-24 11:10 ` Erik Mouw
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Gautam Pagedar @ 2004-02-27 21:03 UTC (permalink / raw)
  To: linux-kernel

Hello Everyboy.
   i am new to this mailing list, so please bear with me if i don't follow
certain rules till i get used to it.  I am a research student and currently
working on a project to tweak the working of 'ls' command depending on my
requirement. I have observed that 'ls' show ALL THE FILES and DIRECTORIES in
a particular location even though a user has no access rights to it. I want
to hide all
such files for that particular user.

The Algorithm i beleive should work like this when an 'ls' command is
called.

1. Check the current directory.
2. Extract the files or directory to be displayed.
3. Check the user permissions for these files.
4. Display only those files wher user had either read, write or execute
access for all owner,group and others.

I have found out that 'ls' uses getdents64() system call for gathering the
directory information. How do i move ahead from here.

Regards,
Gautam Pagedar
Centre for Information and Network Security











^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: can i modify ls
@ 2004-02-24 15:04 James Lamanna
  0 siblings, 0 replies; 10+ messages in thread
From: James Lamanna @ 2004-02-24 15:04 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org

On Sat, Feb 28, 2004 at 02:33:00AM +0530, Gautam Pagedar wrote:
>> i am new to this mailing list, so please bear with me if i don't follow 
>> certain rules till i get used to it. >> I am a research student and 
>> currently working on a project to tweak the working of 'ls' command 
>> depending on >> my requirement. I have observed that 'ls' show ALL THE 
>> FILES and DIRECTORIES in a particular location even >> though a user 
>> has no access rights to it. I want to hide all
>> such files for that particular user.


> It already works like you expect it to do:

> erik@zurix:/tmp/test >mkdir a b
> erik@zurix:/tmp/test >touch a/c
> erik@zurix:/tmp/test >ls -lR
> .:
> total 1
> drwxr-xr-x 2 erik users 72 Feb 24 11:49 a/ ./a:
> total 0
> -rw-r--r-- 1 erik users 0 Feb 24 11:49 c erik@zurix:/tmp/test >chmod -r a
> erik@zurix:/tmp/test >ls -lR
> .:
> total 1
> d-wx--x--x 2 erik users 72 Feb 24 11:49 a/ ls: ./a: Permission denied
> erik@zurix:/tmp/test >chmod -x a
> erik@zurix:/tmp/test >cd a
> a: Permission denied.

I think the behavior that he is looking for is the old behavior that 
Novell Netware used to exhibit - if you don't have any permissions at all, 
it wouldn't list the directory anywhere (at least in windows-type file 
browsers):

james@agard:~/s$ su
Password:
agard:/home/james/s# touch c
agard:/home/james/s# chmod 600 c
agard:/home/james/s# mkdir b
agard:/home/james/s# mkdir a
agard:/home/james/s# chmod 700 a
agard:/home/james/s# ls -alR
.:
total 16
drwxr-xr-x    4 james    james        4096 Feb 23 15:10 .
drwxr-xr-x   48 james    james        4096 Feb 23 15:09 ..
drwx------    2 root     root         4096 Feb 23 15:10 a
drwxr-xr-x    2 root     root         4096 Feb 23 15:10 b
-rw-------    1 root     root            0 Feb 23 15:09 c

./a:
total 8
drwx------    2 root     root         4096 Feb 23 15:10 .
drwxr-xr-x    4 james    james        4096 Feb 23 15:10 ..

./b:
total 8
drwxr-xr-x    2 root     root         4096 Feb 23 15:10 .
drwxr-xr-x    4 james    james        4096 Feb 23 15:10 ..
agard:/home/james/s# exit
exit


james@agard:~/s$ ls -alR
.:
total 16
drwxr-xr-x    4 james    james        4096 Feb 23 15:10 .
drwxr-xr-x   48 james    james        4096 Feb 23 15:09 ..
drwx------    2 root     root         4096 Feb 23 15:10 a
drwxr-xr-x    2 root     root         4096 Feb 23 15:10 b
-rw-------    1 root     root            0 Feb 23 15:09 c
ls: ./a: Permission denied

./b:
total 8
drwxr-xr-x    2 root     root         4096 Feb 23 15:10 .
drwxr-xr-x    4 james    james        4096 Feb 23 15:10 ..
james@agard:~/s$

So in the user directory listing above, he doesn't want the directory a or 
the file c to be displayed at all (since the user doing the ls has no 
permissions on either).

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-02-26 21:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-27 21:03 can i modify ls Gautam Pagedar
2004-02-24 11:10 ` Erik Mouw
2004-02-24 15:55 ` Alessandro Salvatori
2004-02-24 16:35   ` Tomas Szepe
2004-02-24 16:44     ` Richard B. Johnson
2004-02-24 16:59       ` Tomas Szepe
2004-02-24 18:44         ` Richard B. Johnson
2004-02-26 20:56           ` Denis Vlasenko
2004-02-25 15:01 ` Markus Klotzbuecher
  -- strict thread matches above, loose matches on Subject: below --
2004-02-24 15:04 James Lamanna

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox