FYI: safe use of chown ( was Re: kstartupconfig ?)

Stephen Dowdy sdowdy at ucar.edu
Mon Nov 10 05:21:30 GMT 2008


Anne Wilson wrote, On 11/09/08 13:51:

> Funnily enough, I met exactly this error message yesterday.  All I needed to 
> do was to boot into single user mode, then chown -R username:groupname 
> /home/username for the remaining users.

Anne and all,

A tangential word of caution...
(this is mainly for those who admin multi-user systems where
you have to consider your user-base as potentially hostile or
compromised, not necessarily personal/home systems)

# whoami
joe

# cd ; pwd
/home/joe

# ln -s /etc/passwd passwd

Guess what happens when you come along as root and do:

chown -R joe:joegroup /home/joe   ???

/etc/passwd gets owned by 'joe'.  (according to POSIX rules on
symlink dereferencing.  (see chown() and lchown())


I have learned to get in the habit of ALWAYS typing '-h' with '-R':

   chown -hR user:group {dir}

where '-h' specifies to NOT traverse/dereference symlinks.

Because all unix-like distributions behave differently, you may need to figure out
if your linux/unix operates in this fashion and you otherwise may need to use
some combination of 'find -exec' and variant options to not traverse symlinks to do
'chown' operations safely.

--stephen
___________________________________________________
This message is from the kde mailing list.
Account management:  https://mail.kde.org/mailman/listinfo/kde.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.




More information about the kde mailing list