Wednesday, January 26, 2011

Don't Ask

(No, it was not me who made this necessary. Yes, we did reinstall the machine anyway.)
#!/bin/bash
while read p; do
rpm -V $p > /dev/null && continue
echo "fixing $p's file ownership..."
while read x x u g x x x x n x; do
chown -h $u:$g $n
done < <(rpm -qlv $p)
done < <(rpm -qa)

3 comments:

  1. rpm --help | grep set
    --setperms set permissions of files in a package
    --setugids set user/group ownership of files in a package

    that wouldnt have helped you?

    ReplyDelete
  2. Anonymous Coward26 January, 2011 15:11

    I like your script, it is ingenius -- but maybe this would have been sufficien :)
    for p in $(rpm -qa); do rpm --setperms $p; done
    for p in $(rpm -qa); do rpm --setugids $p; done

    ReplyDelete
  3. Hehe, you know, I never stop learning about these things. Next time (let's hope this never happens) I'll read the manpage first... ;)

    ReplyDelete