bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: backwards recursive chowning


From: Bob Proulx
Subject: Re: backwards recursive chowning
Date: Thu, 13 Nov 2003 02:43:16 -0700
User-agent: Mutt/1.3.28i

Evan McNabb wrote:
> Last month I got a new laptop, installed Linux, and "tweaked" my system
> how I liked it. I copied over my personal files in my home directory and
> chowned them all to me.

Hmm...  If they were your files to begin with, wouldn't they have
already been owned by you in the first place?  So maybe the chown was
not needed at all?  Just checking!

> Then I realized that my '.' files still needed to be chowned so I
> made the mistake of typing "chown -R emcnabb:users .*".

Ah, yes, chowning '..' along with everything else.  The common idiom
has been these: .??*, .[!.]* and others.  It is shell dependent.

> I ended up having to reinstall my system because everything was
> owned by me. :-)

This is what I imagine.

  cd /home/you
  chown -R you .*                # warning, matches ..., for the archive

That should only have gotten to /home/* and not to the rest of your
system.  So I am not sure how that would have damaged your system as
extensively as you describe.

Let me recommend that next time you copy the files as you to begin
with.  Then you will naturally own the files.  And not being root
would have protected your system from this.  Working as root is like
running with a long knife.  The edge can be sharp.

> It turns out that lots of my friends have done the same thing (so this
> is a request from several people). Is there any possibility to get all
> the programs in coreutils (chown, chmod, chgrp, etc) to not have
> backwards recursion (i.e.  that follow '..')?

The problem is that this is not something that the commands know
about.  Files are files and directories are directores and the names
don't mean anything.  Also the shell (e.g. /bin/bash) is doing the
expansion.  So the command does not have any idea that file globbing
was involved.  This is actually an FAQ.  Check this out.

  http://www.gnu.org/software/coreutils/faq/coreutils-faq.html

Look for "globbing" and "echo" where this is described.  It is not
exactly this case but the rest of the description might be useful.

> I know rm doesn't do this any more, and that has saved many people's
> systems.

Huh?  There isn't any special code in there.  But I did see a very
huge long debate in the standards list about whether it should
specifically allow a system to implement such a check.  It would be
very difficult to do that in practice however.

In any case, it is unfortunate that you needed to reinstall.  Glad you
had not had too terribly much into the last installation.  Some people
never get the experience of why root can be a dangerous thing.  You
can now tell them from personal experience.  Unfortunately most
experience is measured by the toothmarks in your rear end.

Bob

Attachment: pgpP67YHthHIq.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]