Bob Crandell wrote:

> I'm trying to rescue a guy's server.  It has a couple of hundred
> accounts on it.  I ran this script from kbob:

Yeah, sure, now it's MY fault! (-:

> (cd ${SOURCE}; /bin/tar cvf - .) | (cd ${DESTIN}; /bin/tar xvfp -)

Maybe you weren't root when you ran it?

A terser way to do that is this.

        # cp -a $SOURCE $DESTIN

I didn't know about -a until recently.  It wasn't in the cp command
long ago.

> It isn't keeping the ownership of the source.  Can someone come up
> with a quick and dirty way of reading /etc/passwd and assiging the
> original permissions to /home/$USER ?  Please?

perl -F: -nae 'print "find $F[5] -exec chown $F[2]:$F[3]\"{}\"\";\"\n" if $F[5] =~ 
m./home/.' /etc/passwd | sh -x

Is that dirty enough for you?  (-:  I strongly suggest running it
without the "| sh -x" part on the end so you see what it's going to
do, then add "| sh -x" to actually do it.

The comand uses perl to search through /etc/passwd.  For each line
in passwd, if the user's home directory starts with /home/, then
it creates this command:

        find HOMEDIR -exec chown UID:GID "{}" ";'

(where HOMEDIR, UID and GID are taken from the passwd entry.)

The perl script just prints those find commands.  Passing them
to a shell executes them.  The find command executes "chown UID:GID file"
on every file in the directory tree.

You'll want to check /home for special accounts like /home/ftp or
/home/httpd where the user shouldn't own the files in the directory

> The other Bob

I guess that makes me the Other Other Bob.  Do we have any other
Other Other Bobs on this list?

-- 
Bob Miller                              K<bob>
kbobsoft software consulting
http://kbobsoft.com                     [EMAIL PROTECTED]
_______________________________________________
EuG-LUG mailing list
[EMAIL PROTECTED]
http://mailman.efn.org/cgi-bin/listinfo/eug-lug

Reply via email to