Recovering file attributes from snapshot

Andy Bair pab at korelogic.com
Tue Jul 3 17:46:30 EDT 2007


You are correct.  The FTimes project does not have a script to do the
conversion you are describing, but this script should do the trick.  Let
me know if this is what you are looking for, or not.

--- ftimes2chown.sh ---
#!/bin/sh

ftimes --mapauto none+uid+gid -l 6 /etc | tail +2 | \
while read LINE; do
  FILE=`echo ${LINE} | sed -e 's#^"/etc/##' -e 's/".*//'`
  MY_UID=`echo ${LINE} | cut -d\| -f2`
  MY_GID=`echo ${LINE} | cut -d\| -f3`
  if [ ! -z "${FILE}" ]; then
    chown ${MY_UID}:${MY_GID} ${FILE}
  fi
done
--- ftimes2chown.sh ---

Andy


On Tue, Jul 03, 2007 at 04:31:28PM -0400, Michael ODonnell wrote:
> 
> 
> Here's a recipe for creating a situation like the one I'm
> dealing with:
> 
>    mkdir /tmp/etc.b0rken
>    cd    /tmp/etc.b0rken
>    cp -a /etc/. .
>    chmod -R a+rwx .
>    chown 1234.5678 $( find . -type d )
>    chown 2468.1357 $( find . -type f )
> 
> ...after which you'll have a hierarchy in /tmp/etc.b0rken 
> that's extremely b0rken WRT the real /etc just as my files
> are b0rken WRT to their desired conditions.  The goal is to
> now be able to stand in /tmp/etc.b0rken and force all UIDs,
> GIDs and permissions back to match those in the real /etc.
> 
> Note that I appreciate your suggestion and I'm not asking you
> to script my solution for me, just pointing out that while the
> FTimes suite can certainly help you detect b0rken attributes
> it (apparently) does not help you correct them...

No problem.  You are correct.

>  
> _______________________________________________
> gnhlug-discuss mailing list
> gnhlug-discuss at mail.gnhlug.org
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/

-- 
Andy

KoreLogic Security
603.465.3236 (Office)
603.340.2498 (Mobile)
http://www.korelogic.com
GnuPG Fingerprint: 688A 79EC B1E5 5748 CE87  1F20 2C45 60E7 0583 23B6


More information about the gnhlug-discuss mailing list