* Re: x bit for dirs: misfeature?
2001-11-19 16:58 ` vda
@ 2001-11-19 15:04 ` Tim Waugh
2001-11-19 15:29 ` Richard B. Johnson
2001-11-19 16:00 ` James A Sutherland
` (3 subsequent siblings)
4 siblings, 1 reply; 40+ messages in thread
From: Tim Waugh @ 2001-11-19 15:04 UTC (permalink / raw)
To: vda; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 220 bytes --]
On Mon, Nov 19, 2001 at 04:58:38PM +0000, vda wrote:
> I know. I'd like to hear anybody who have a directory with r!=x
> on purpose (and quite curious on that purpose). UNIX gugus, anybody?
ftp://.../incoming
Tim.
*/
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: x bit for dirs: misfeature?
2001-11-19 15:04 ` Tim Waugh
@ 2001-11-19 15:29 ` Richard B. Johnson
0 siblings, 0 replies; 40+ messages in thread
From: Richard B. Johnson @ 2001-11-19 15:29 UTC (permalink / raw)
To: Tim Waugh; +Cc: vda, linux-kernel
On Mon, 19 Nov 2001, Tim Waugh wrote:
> On Mon, Nov 19, 2001 at 04:58:38PM +0000, vda wrote:
>
> > I know. I'd like to hear anybody who have a directory with r!=x
> > on purpose (and quite curious on that purpose). UNIX gugus, anybody?
>
> ftp://.../incoming
>
> Tim.
> */
>
It doesn't make any difference if it's useful. It is a de-facto
standard. Therefore, it must exist. It's just like all the stuff
in the C runtime library you never use like bcopy()!
If everybody in the world wanted to get rid of that dumb bit,
you still couldn't do it. It needs to exists for no other reason
than it has existed.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).
I was going to compile a list of innovations that could be
attributed to Microsoft. Once I realized that Ctrl-Alt-Del
was handled in the BIOS, I found that there aren't any.
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: x bit for dirs: misfeature?
2001-11-19 16:58 ` vda
2001-11-19 15:04 ` Tim Waugh
@ 2001-11-19 16:00 ` James A Sutherland
2001-11-19 17:43 ` Kai Henningsen
2001-11-19 18:24 ` vda
2001-11-19 16:47 ` Jesse Pollard
` (2 subsequent siblings)
4 siblings, 2 replies; 40+ messages in thread
From: James A Sutherland @ 2001-11-19 16:00 UTC (permalink / raw)
To: vda, linux-kernel
On Monday 19 November 2001 4:58 pm, vda wrote:
> On Monday 19 November 2001 14:36, James A Sutherland wrote:
> > $ mkdir test
> > $ echo content > test/file
> > $ chmod a-r test
> > $ ls test
> > ls: test: permission denied
> > $ cat test/file
> > content
> > $ chmod a=r test
> > $ ls test
> > ls: test/file: Permission denied
>
> Hmm... I do actually tested this and last command succeeds
> (shows dir contents). You probably meant cat test/file, not ls...
Nope, ls.
[james@dax p2i]$ ls test
ls: test/file: Permission denied
[james@dax p2i]$ ls -l test
ls: test/file: Permission denied
total 0
(There is something incredibly stupid about the first one: ls is unable to,
er, read the name of the named file?!)
Anyway, as Al Viro has pointed out, R!=X. It's been like that for a very long
time, it's deliberate, not a misfeature, and it's staying like that for the
foreseeable future.
James.
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: x bit for dirs: misfeature?
2001-11-19 16:00 ` James A Sutherland
@ 2001-11-19 17:43 ` Kai Henningsen
2001-11-19 18:24 ` vda
1 sibling, 0 replies; 40+ messages in thread
From: Kai Henningsen @ 2001-11-19 17:43 UTC (permalink / raw)
To: linux-kernel
jas88@cam.ac.uk (James A Sutherland) wrote on 19.11.01 in <E165qq7-0003QD-00@mauve.csi.cam.ac.uk>:
> [james@dax p2i]$ ls test
> ls: test/file: Permission denied
> [james@dax p2i]$ ls -l test
> ls: test/file: Permission denied
> total 0
>
> (There is something incredibly stupid about the first one: ls is unable to,
> er, read the name of the named file?!)
Try 'ls --color=none'. Then go read 'info ls'.
MfG Kai
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: x bit for dirs: misfeature?
2001-11-19 16:00 ` James A Sutherland
2001-11-19 17:43 ` Kai Henningsen
@ 2001-11-19 18:24 ` vda
2001-11-19 16:44 ` Horst von Brand
1 sibling, 1 reply; 40+ messages in thread
From: vda @ 2001-11-19 18:24 UTC (permalink / raw)
To: James A Sutherland, linux-kernel
On Monday 19 November 2001 16:00, you wrote:
> On Monday 19 November 2001 4:58 pm, vda wrote:
> > On Monday 19 November 2001 14:36, James A Sutherland wrote:
> > > $ mkdir test
> > > $ echo content > test/file
> > > $ chmod a-r test
> > > $ ls test
> > > ls: test: permission denied
> > > $ cat test/file
> > > content
> > > $ chmod a=r test
> > > $ ls test
> > > ls: test/file: Permission denied
> >
> > Hmm... I do actually tested this and last command succeeds
> > (shows dir contents). You probably meant cat test/file, not ls...
>
> Nope, ls.
>
> [james@dax p2i]$ ls test
> ls: test/file: Permission denied
> [james@dax p2i]$ ls -l test
> ls: test/file: Permission denied
> total 0
Looks like we have different ls :-). Mine lists 'r only' dir with no problem.
> Anyway, as Al Viro has pointed out, R!=X. It's been like that for a very
> long time, it's deliberate, not a misfeature, and it's staying like that
> for the foreseeable future.
Yes, I see... All I can do is to add workarounds (ok,ok, 'support')
to chmod and friends:
chmod -R a+R dir - sets r for files and rx for dirs
--
vda
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: x bit for dirs: misfeature?
2001-11-19 18:24 ` vda
@ 2001-11-19 16:44 ` Horst von Brand
2001-11-19 17:24 ` James A Sutherland
2001-11-19 19:21 ` vda
0 siblings, 2 replies; 40+ messages in thread
From: Horst von Brand @ 2001-11-19 16:44 UTC (permalink / raw)
To: vda; +Cc: James A Sutherland, linux-kernel
vda <vda@port.imtp.ilyichevsk.odessa.ua> said:
[...]
> > [james@dax p2i]$ ls test
> > ls: test/file: Permission denied
> > [james@dax p2i]$ ls -l test
> > ls: test/file: Permission denied
> > total 0
>
> Looks like we have different ls :-). Mine lists 'r only' dir with no
> problem.
Probably some alias. "/bin/ls test" should work, "/bin/ls -l test" won't.
> > Anyway, as Al Viro has pointed out, R!=X. It's been like that for a very
> > long time, it's deliberate, not a misfeature, and it's staying like that
> > for the foreseeable future.
>
> Yes, I see... All I can do is to add workarounds (ok,ok, 'support')
> to chmod and friends:
>
> chmod -R a+R dir - sets r for files and rx for dirs
X sets x for dirs, leaves files alone.
--
Dr. Horst H. von Brand User #22616 counter.li.org
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: x bit for dirs: misfeature?
2001-11-19 16:44 ` Horst von Brand
@ 2001-11-19 17:24 ` James A Sutherland
2001-11-19 19:39 ` vda
2001-11-19 19:21 ` vda
1 sibling, 1 reply; 40+ messages in thread
From: James A Sutherland @ 2001-11-19 17:24 UTC (permalink / raw)
To: Horst von Brand, vda; +Cc: linux-kernel
On Monday 19 November 2001 4:44 pm, Horst von Brand wrote:
> vda <vda@port.imtp.ilyichevsk.odessa.ua> said:
>
> [...]
>
> > > [james@dax p2i]$ ls test
> > > ls: test/file: Permission denied
> > > [james@dax p2i]$ ls -l test
> > > ls: test/file: Permission denied
> > > total 0
> >
> > Looks like we have different ls :-). Mine lists 'r only' dir with no
> > problem.
>
> Probably some alias. "/bin/ls test" should work, "/bin/ls -l test" won't.
Correct: my default ls is trying to stat the files to pick a pretty color for
them...
> > > Anyway, as Al Viro has pointed out, R!=X. It's been like that for a
> > > very long time, it's deliberate, not a misfeature, and it's staying
> > > like that for the foreseeable future.
> >
> > Yes, I see... All I can do is to add workarounds (ok,ok, 'support')
> > to chmod and friends:
> >
> > chmod -R a+R dir - sets r for files and rx for dirs
>
> X sets x for dirs, leaves files alone.
Which sounds like exactly the behaviour the original poster wanted, AFAICS?
James.
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: x bit for dirs: misfeature?
2001-11-19 17:24 ` James A Sutherland
@ 2001-11-19 19:39 ` vda
2001-11-19 19:07 ` James A Sutherland
2001-11-19 21:01 ` Flavio Stanchina
0 siblings, 2 replies; 40+ messages in thread
From: vda @ 2001-11-19 19:39 UTC (permalink / raw)
To: James A Sutherland, Horst von Brand; +Cc: linux-kernel
On Monday 19 November 2001 17:24, James A Sutherland wrote:
> > > Yes, I see... All I can do is to add workarounds (ok,ok, 'support')
> > > to chmod and friends:
> > >
> > > chmod -R a+R dir - sets r for files and rx for dirs
> >
> > X sets x for dirs, leaves files alone.
>
> Which sounds like exactly the behaviour the original poster wanted, AFAICS?
Yes, that sounds like the behaviour I want. But X flag does not do that.
Sorry.
James, I don't like flame wars. Lets ask ourself: does this thread have any
useful results? Unfortunately, not many.
Patches for chmod source would be better. Perhaps I should do that...
Let's refrain from "you're fool... go read manpage" type
discussions. Not productive.
--
vda
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: x bit for dirs: misfeature?
2001-11-19 19:39 ` vda
@ 2001-11-19 19:07 ` James A Sutherland
2001-11-20 13:03 ` vda
2001-11-19 21:01 ` Flavio Stanchina
1 sibling, 1 reply; 40+ messages in thread
From: James A Sutherland @ 2001-11-19 19:07 UTC (permalink / raw)
To: vda, Horst von Brand; +Cc: linux-kernel
On Monday 19 November 2001 7:39 pm, vda wrote:
> On Monday 19 November 2001 17:24, James A Sutherland wrote:
> > > > Yes, I see... All I can do is to add workarounds (ok,ok, 'support')
> > > > to chmod and friends:
> > > >
> > > > chmod -R a+R dir - sets r for files and rx for dirs
> > >
> > > X sets x for dirs, leaves files alone.
> >
> > Which sounds like exactly the behaviour the original poster wanted,
> > AFAICS?
>
> Yes, that sounds like the behaviour I want. But X flag does not do that.
> Sorry.
Oh? I just checked, and X *does* set the x bit on directories only, leaving
files unaffected. What's wrong with that? Does it not do this on your system?
Or do you want some other behaviour?
> James, I don't like flame wars. Lets ask ourself: does this thread have any
> useful results? Unfortunately, not many.
> Patches for chmod source would be better. Perhaps I should do that...
Patch it to do what? The current behaviour seems to me to be what you want...
> Let's refrain from "you're fool... go read manpage" type
> discussions. Not productive.
Agreed - if the question were covered in a manpage, I doubt there would be a
thread here on LKML about it :)
James.
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: x bit for dirs: misfeature?
2001-11-19 19:07 ` James A Sutherland
@ 2001-11-20 13:03 ` vda
0 siblings, 0 replies; 40+ messages in thread
From: vda @ 2001-11-20 13:03 UTC (permalink / raw)
To: James A Sutherland, Horst von Brand; +Cc: linux-kernel
On Monday 19 November 2001 19:07, James A Sutherland wrote:
> On Monday 19 November 2001 7:39 pm, vda wrote:
> > On Monday 19 November 2001 17:24, James A Sutherland wrote:
> > > > > Yes, I see... All I can do is to add workarounds (ok,ok, 'support')
> > > > > to chmod and friends:
> > > > >
> > > > > chmod -R a+R dir - sets r for files and rx for dirs
> > > >
> > > > X sets x for dirs, leaves files alone.
> > >
> > > Which sounds like exactly the behaviour the original poster wanted,
> > > AFAICS?
> >
> > Yes, that sounds like the behaviour I want. But X flag does not do that.
> > Sorry.
>
> Oh? I just checked, and X *does* set the x bit on directories only, leaving
> files unaffected. What's wrong with that? Does it not do this on your
> system? Or do you want some other behaviour?
I just checked it too (not olny read the manpage but conducted an
experiment). If a file has any of three x bits set, chmod a+X will
set all three x bits, making it world-executable.
That is not what I want. I want to make whole tree world-readable (and
browsable), i.e. a+r on files and a+rx on dirs. There is no chmod flag
which will do that.
[I'd like to take this silliness off the lkml but jas88@cam.ac.uk
rejects my direct emails:
----- Transcript of session follows -----
... while talking to navy.csi.cam.ac.uk.:
>>> RCPT To:<jas88@cam.ac.uk>
<<< 550 mail from 195.66.192.167 rejected: administrative prohibition (host
is blacklisted)
550 5.1.1 <jas88@cam.ac.uk>... User unknown ]
--
vda
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: x bit for dirs: misfeature?
2001-11-19 19:39 ` vda
2001-11-19 19:07 ` James A Sutherland
@ 2001-11-19 21:01 ` Flavio Stanchina
1 sibling, 0 replies; 40+ messages in thread
From: Flavio Stanchina @ 2001-11-19 21:01 UTC (permalink / raw)
To: vda; +Cc: linux-kernel
On Monday 19 November 2001 20:39, vda wrote:
> Patches for chmod source would be better. Perhaps I should do that...
> Let's refrain from "you're fool... go read manpage" type
> discussions. Not productive.
Calling you a fool would certainly be stupid, however you are arguing
about a feature that Unix filesystems have had since the beginning of time
and that every sysadmin uses quite frequently (as described in several
posts) so you're not going to get much support, not on LKML at least. ;-)
Patching chmod to add a new option would save some typing once in a while,
but if you find yourself doing such chmod'ing often the very obvious
solution (which was already proposed) is
find -type d -exec chmod +x \{\} \;
eventually wrapped in a script, alias or whatever. That's what Unices are
good for: you can easily build new utilities by combining existing ones,
no need to patch anything.
Some might agree that assigning different purposes to the 'x' bit for
files and directories might be confusing, but there's a fix for that too:
just think "eXplore" instead of "eXecute" when you look at directories.
Now one could start arguing about the setgid bit too, and that's more
dangerous than the execute/explore bit, but again, it always worked that
way and it ain't gonna change anytime soon.
--
Ciao,
Flavio Stanchina
Trento - Italy
"The best defense against logic is ignorance."
http://spazioweb.inwind.it/fstanchina/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: x bit for dirs: misfeature?
2001-11-19 16:44 ` Horst von Brand
2001-11-19 17:24 ` James A Sutherland
@ 2001-11-19 19:21 ` vda
2001-11-19 18:14 ` Horst von Brand
1 sibling, 1 reply; 40+ messages in thread
From: vda @ 2001-11-19 19:21 UTC (permalink / raw)
To: Horst von Brand; +Cc: James A Sutherland, linux-kernel
On Monday 19 November 2001 16:44, Horst von Brand wrote:
> > > Anyway, as Al Viro has pointed out, R!=X. It's been like that for a
> > > very long time, it's deliberate, not a misfeature, and it's staying
> > > like that for the foreseeable future.
> >
> > Yes, I see... All I can do is to add workarounds (ok,ok, 'support')
> > to chmod and friends:
> >
> > chmod -R a+R dir - sets r for files and rx for dirs
>
> X sets x for dirs, leaves files alone.
Hmm... yes this is one of such workarounds already implemented.
But it is not very good for my example:
X sets x for dirs *and* for files with x set for any of u,g,o.
# chmod -R a+rX dir
will make any executables (even root only) world-executable.
That's why I'd like to add new flag to chmod: R.
--
vda
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: x bit for dirs: misfeature?
2001-11-19 19:21 ` vda
@ 2001-11-19 18:14 ` Horst von Brand
2001-11-20 11:20 ` Anton Altaparmakov
2001-11-20 12:58 ` vda
0 siblings, 2 replies; 40+ messages in thread
From: Horst von Brand @ 2001-11-19 18:14 UTC (permalink / raw)
To: vda; +Cc: James A Sutherland, linux-kernel
vda <vda@port.imtp.ilyichevsk.odessa.ua> said:
> On Monday 19 November 2001 16:44, Horst von Brand wrote:
[...]
> > X sets x for dirs, leaves files alone.
> Hmm... yes this is one of such workarounds already implemented.
> But it is not very good for my example:
> X sets x for dirs *and* for files with x set for any of u,g,o.
>
> # chmod -R a+rX dir
>
> will make any executables (even root only) world-executable.
That's what you are asking for...
--
Dr. Horst H. von Brand User #22616 counter.li.org
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: x bit for dirs: misfeature?
2001-11-19 18:14 ` Horst von Brand
@ 2001-11-20 11:20 ` Anton Altaparmakov
2001-11-20 12:01 ` Alexander Viro
` (2 more replies)
2001-11-20 12:58 ` vda
1 sibling, 3 replies; 40+ messages in thread
From: Anton Altaparmakov @ 2001-11-20 11:20 UTC (permalink / raw)
To: vda; +Cc: Horst von Brand, James A Sutherland, linux-kernel
At 12:58 20/11/01, vda wrote:
>I'm asking for ability to make a tree _world-readable_ (and
>browsable), i.e. a+r on files and a+rx on dirs.
>There is currently no chmod flag which will do that.
So what? The following two commands do exactly that:
find . -type d -exec chmod a+rx "{}" \;
find . -type f -exec chmod a+r "{}" \;
Just stick them in a shell script and call the script chmod-world-readable
and stop complaining...
You would obviously want to change the "." to be $1 so it is the 1st
argument to the script...
It will be a bit slow and can be optimized endlessly but it will do the
trick and you probably won't be running it that often so speed is not an
issue... And if it is then grab the chmod sources and add the wanted
functionality with a new swich and be done with it.
This is WAY Off Topic for Linux kernel!
Best regards,
Anton
--
"I've not lost my mind. It's backed up on tape somewhere." - Unknown
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Linux NTFS Maintainer / WWW: http://linux-ntfs.sf.net/
ICQ: 8561279 / WWW: http://www-stu.christs.cam.ac.uk/~aia21/
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: x bit for dirs: misfeature?
2001-11-20 11:20 ` Anton Altaparmakov
@ 2001-11-20 12:01 ` Alexander Viro
2001-11-20 15:08 ` Anton Altaparmakov
2001-11-20 17:18 ` Mike Castle
2 siblings, 0 replies; 40+ messages in thread
From: Alexander Viro @ 2001-11-20 12:01 UTC (permalink / raw)
To: Anton Altaparmakov; +Cc: vda, Horst von Brand, James A Sutherland, linux-kernel
On Tue, 20 Nov 2001, Anton Altaparmakov wrote:
> So what? The following two commands do exactly that:
>
> find . -type d -exec chmod a+rx "{}" \;
> find . -type f -exec chmod a+r "{}" \;
>
> Just stick them in a shell script and call the script chmod-world-readable
> and stop complaining...
Just don't do that if that subtree contains a directory writable to somebody
else. There is a nasty attack here.
Think what happens if root does that for /tmp/foo and some luser has write
permissions on /tmp/foo/bar. There is a window between execve() on chmod(1)
and call of chmod(2) and during that window luser can replace /tmp/foo/bar/baz
to symlink to /etc and leave root doing chmod("/tmp/foo/bar/baz/shadow", 0744);
Not that chmod(1) was any better at that... It should've been keeping
all chain between the root of subtree and parent of file we currently
handling opened and do open()/fstat()/fchdir() to go down and fchdir()
to go up. Then all calls of chmod(2) would be for files in current
directory, which prevents symlink attacks.
Moral: think _very_ hard when you write any tree-walking code that will
ever be used on a tree writable to somebody else.
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: x bit for dirs: misfeature?
2001-11-20 11:20 ` Anton Altaparmakov
2001-11-20 12:01 ` Alexander Viro
@ 2001-11-20 15:08 ` Anton Altaparmakov
2001-11-20 17:18 ` Mike Castle
2 siblings, 0 replies; 40+ messages in thread
From: Anton Altaparmakov @ 2001-11-20 15:08 UTC (permalink / raw)
To: Alexander Viro; +Cc: vda, Horst von Brand, James A Sutherland, linux-kernel
At 12:01 20/11/01, Alexander Viro wrote:
>On Tue, 20 Nov 2001, Anton Altaparmakov wrote:
> > So what? The following two commands do exactly that:
> >
> > find . -type d -exec chmod a+rx "{}" \;
> > find . -type f -exec chmod a+r "{}" \;
> >
> > Just stick them in a shell script and call the script chmod-world-readable
> > and stop complaining...
>
>Just don't do that if that subtree contains a directory writable to somebody
>else. There is a nasty attack here.
Ok. But I assume the application for this is something like /usr/share to
which noone would have write privileges to (I would hope). I doubt anyone
would want to run it on /home... and if they do they most likely don't care
about security too much anyway... (-;
>Think what happens if root does that for /tmp/foo and some luser has write
>permissions on /tmp/foo/bar. There is a window between execve() on chmod(1)
>and call of chmod(2) and during that window luser can replace /tmp/foo/bar/baz
>to symlink to /etc and leave root doing chmod("/tmp/foo/bar/baz/shadow",
>0744);
>
>Not that chmod(1) was any better at that... It should've been keeping
>all chain between the root of subtree and parent of file we currently
>handling opened and do open()/fstat()/fchdir() to go down and fchdir()
>to go up. Then all calls of chmod(2) would be for files in current
>directory, which prevents symlink attacks.
>
>Moral: think _very_ hard when you write any tree-walking code that will
>ever be used on a tree writable to somebody else.
Point taken. I will keep it in mind when implementing ACLs (and ACL
inheritance in particular) in NTFS. That will involve walking back to the
volume's root to establish the inherited rights... which might perhaps lend
itself to simillar abuse.
Cheers,
Anton
--
"I've not lost my mind. It's backed up on tape somewhere." - Unknown
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Linux NTFS Maintainer / WWW: http://linux-ntfs.sf.net/
ICQ: 8561279 / WWW: http://www-stu.christs.cam.ac.uk/~aia21/
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: x bit for dirs: misfeature?
2001-11-20 11:20 ` Anton Altaparmakov
2001-11-20 12:01 ` Alexander Viro
2001-11-20 15:08 ` Anton Altaparmakov
@ 2001-11-20 17:18 ` Mike Castle
2001-11-20 17:37 ` Alexander Viro
2 siblings, 1 reply; 40+ messages in thread
From: Mike Castle @ 2001-11-20 17:18 UTC (permalink / raw)
To: linux-kernel
On Tue, Nov 20, 2001 at 11:20:06AM +0000, Anton Altaparmakov wrote:
> find . -type d -exec chmod a+rx "{}" \;
> find . -type f -exec chmod a+r "{}" \;
That is a bit inefficient though. It results in one fork/exec pair for
each file and each directory.
A better solution is to use find | xargs
find /path/to/dir -type d -print0 | xargs -0 chmod a+rx
find /path/to/dir -type f -print0 | xargs -0 chmod a+r
That way, xargs bunches up the arguments into as many arguments as chmod
can handle, and calls it fewer times.
The -print0 and -0 are GNU extensions to handle spaces in names.
mrc
--
Mike Castle dalgoda@ix.netcom.com www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: x bit for dirs: misfeature?
2001-11-20 17:18 ` Mike Castle
@ 2001-11-20 17:37 ` Alexander Viro
0 siblings, 0 replies; 40+ messages in thread
From: Alexander Viro @ 2001-11-20 17:37 UTC (permalink / raw)
To: Mike Castle; +Cc: linux-kernel
On Tue, 20 Nov 2001, Mike Castle wrote:
> find /path/to/dir -type d -print0 | xargs -0 chmod a+rx
> find /path/to/dir -type f -print0 | xargs -0 chmod a+r
>
> That way, xargs bunches up the arguments into as many arguments as chmod
> can handle, and calls it fewer times.
>
> The -print0 and -0 are GNU extensions to handle spaces in names.
That's even worse than original. You've got a very wide race here -
think what happens if luser does
cd /path/to/dir/something/writable/to/luser
mkdir bar
mkdir baz
for i in `seq 1 500`; do
mkdir bar/$i
touch bar/$i/shadow
ln -sf /etc baz/$i
done
before you start, then waits for first chmod a+r and does
mv bar quux; mv baz bar
leaving you with very interesting results. It's much wider window than
in the original.
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: x bit for dirs: misfeature?
2001-11-19 18:14 ` Horst von Brand
2001-11-20 11:20 ` Anton Altaparmakov
@ 2001-11-20 12:58 ` vda
1 sibling, 0 replies; 40+ messages in thread
From: vda @ 2001-11-20 12:58 UTC (permalink / raw)
To: Horst von Brand; +Cc: James A Sutherland, linux-kernel
On Monday 19 November 2001 18:14, Horst von Brand wrote:
> vda <vda@port.imtp.ilyichevsk.odessa.ua> said:
> > On Monday 19 November 2001 16:44, Horst von Brand wrote:
>
> [...]
>
> > > X sets x for dirs, leaves files alone.
> >
> > Hmm... yes this is one of such workarounds already implemented.
> > But it is not very good for my example:
> > X sets x for dirs *and* for files with x set for any of u,g,o.
> >
> > # chmod -R a+rX dir
> >
> > will make any executables (even root only) world-executable.
>
> That's what you are asking for...
?!
I'm asking for ability to make a tree _world-readable_ (and
browsable), i.e. a+r on files and a+rx on dirs.
There is currently no chmod flag which will do that.
--
vda
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: x bit for dirs: misfeature?
2001-11-19 16:58 ` vda
2001-11-19 15:04 ` Tim Waugh
2001-11-19 16:00 ` James A Sutherland
@ 2001-11-19 16:47 ` Jesse Pollard
2001-11-19 17:15 ` David Ford
2001-11-19 17:37 ` Pascal Schmidt
2001-11-19 18:42 ` J Sloan
4 siblings, 1 reply; 40+ messages in thread
From: Jesse Pollard @ 2001-11-19 16:47 UTC (permalink / raw)
To: vda, James A Sutherland, linux-kernel
vda <vda@port.imtp.ilyichevsk.odessa.ua>
>
> On Monday 19 November 2001 14:36, James A Sutherland wrote:
> > On Monday 19 November 2001 4:22 pm, vda wrote:
> > > Everytime I do 'chmod -R a+rX dir' and wonder are there
> > > any executables which I don't want to become world executable,
> > > I think "Whatta hell with this x bit meaning 'can browse'
> > > for dirs?! Who was that clever guy who invented that? Grrrr"
> > >
> > > Isn't r sufficient? Can we deprecate x for dirs?
> > > I.e. make it a mirror of r: you set r, you see x set,
> > > you clear r, you see x cleared, set/clear x = nop?
> > >
> > > Benefits:
> > > chmod -R go-x dir (ensure there is no executables)
> > > chmod -R a+r dir (make tree world readable)
> > > mount -t vfat -o umask=644 /dev/xxx dir
> > > (I don't want all files to be flagged as executables there)
> > >
> > > These commands will do what I want without (sometimes ugly) tricks.
> > > For mount, I can't even see how to do it with current implementation.
> > >
> > > What standards will be broken?
> > > Any real loss of functionality apart from compat issues?
>
> > The R and X bits on directories have different meanings. Watch:
>
> I know. I'd like to hear anybody who have a directory with r!=x
> on purpose (and quite curious on that purpose). UNIX gugus, anybody?
It's used to hide files in anonymous FTP for for one. It prevents you from
retrieving files that you don't know the name of. Yes, a brute force attempt
to open MAY work to find the unknown file, it will take a long time, and you
are most likely to be detected. The anonymous FTP use is usually in an incoming
directory - the files are put there from remote individuals, and are hidden
(unless someone is a good guesser/or a poor name chosen) until the
administrator examines/moves them.
>
> > $ mkdir test
> > $ echo content > test/file
> > $ chmod a-r test
> > $ ls test
> > ls: test: permission denied
> > $ cat test/file
> > content
> > $ chmod a=r test
> > $ ls test
> > ls: test/file: Permission denied
>
> Hmm... I do actually tested this and last command succeeds
> (shows dir contents). You probably meant cat test/file, not ls...
>
> > In short, the X bit allows you to access the contents of the directory,
> > while R allows you to LIST those contents. There are valid uses for X only
> > directories (i.e. users are not allowed to list the contents, only to
> > access them directly by name). R-only directories make little sense, as you
> > can see from the transcript above :)
It's there for consistancy/simplisity. Mode bits for directories are treated
the same as they are for any other type of file.
-------------------------------------------------------------------------
Jesse I Pollard, II
Email: pollard@navo.hpc.mil
Any opinions expressed are solely my own.
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: x bit for dirs: misfeature?
2001-11-19 16:47 ` Jesse Pollard
@ 2001-11-19 17:15 ` David Ford
0 siblings, 0 replies; 40+ messages in thread
From: David Ford @ 2001-11-19 17:15 UTC (permalink / raw)
To: Jesse Pollard; +Cc: vda, James A Sutherland, linux-kernel
>
>
>>I know. I'd like to hear anybody who have a directory with r!=x
>>on purpose (and quite curious on that purpose). UNIX gugus, anybody?
>>
>
>It's used to hide files in anonymous FTP for for one. It prevents you from
>retrieving files that you don't know the name of. Yes, a brute force attempt
>to open MAY work to find the unknown file, it will take a long time, and you
>are most likely to be detected. The anonymous FTP use is usually in an incoming
>directory - the files are put there from remote individuals, and are hidden
>(unless someone is a good guesser/or a poor name chosen) until the
>administrator examines/moves them.
>
I use it for more than just ftp. I chmod 710 ~ and have ~ in the
web/email groups. It stops prying eyes unless they know what the
filename is.
David
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: x bit for dirs: misfeature?
2001-11-19 16:58 ` vda
` (2 preceding siblings ...)
2001-11-19 16:47 ` Jesse Pollard
@ 2001-11-19 17:37 ` Pascal Schmidt
2001-11-19 18:42 ` J Sloan
4 siblings, 0 replies; 40+ messages in thread
From: Pascal Schmidt @ 2001-11-19 17:37 UTC (permalink / raw)
To: vda; +Cc: James A Sutherland, linux-kernel
On Mon, 19 Nov 2001, vda wrote:
> I know. I'd like to hear anybody who have a directory with r!=x
> on purpose (and quite curious on that purpose). UNIX gugus, anybody?
When you have a web server running with user homepages in $HOME/www or
similar, users need to have x set for the web server to serve their pages,
but some users may not want all other users to see what files they have.
Those people will have --x permission for other on their $HOME.
--
Ciao, Pascal
-<[ pharao90@tzi.de, netmail 2:241/215.72, home http://cobol.cjb.net/) ]>-
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: x bit for dirs: misfeature?
2001-11-19 16:58 ` vda
` (3 preceding siblings ...)
2001-11-19 17:37 ` Pascal Schmidt
@ 2001-11-19 18:42 ` J Sloan
4 siblings, 0 replies; 40+ messages in thread
From: J Sloan @ 2001-11-19 18:42 UTC (permalink / raw)
To: vda; +Cc: James A Sutherland, linux-kernel
vda wrote:
> I know. I'd like to hear anybody who have a directory with r!=x
> on purpose (and quite curious on that purpose). UNIX gugus, anybody?
Absolutely -
It is quite common to have dirs with perms 711 -
This allows arbitrary users to copy specific files
from such a directory, but does not allow them to
cd into that directory or to browse it.
Losing that distinction would be crippling.
cu
jjs
^ permalink raw reply [flat|nested] 40+ messages in thread