Hey Dan,

        RPM has a fairly groovey feature which will let you reset the
permissions to match their stored values in the rpm database.  For
starters something like...

        rpm -q -a | xargs rpm --setperms

... will set most of your box to rights.  Except there are quite a few
'unowned' files in /etc so..  Assuming I didn't misunderstand your problem
I think this should work out... 

M.

#!/usr/bin/perl

use strict;
use File::Basename;
use IO::File;
use vars qw / $backdir $backfile $targdir $targfile /;
use vars qw / $mode $f /;

$backdir = "/mnt/backups/etc";
$targdir = "/etc";

$f = new IO::File;
open ($f, "find $targdir|") || die "Find failed: $targdir: $!\n";

while (<$f>) {
        chomp($targfile = $_);

        $backfile = $targfile;
        $backfile =~ s/^$targdir//;
        $backfile = $backdir . "/" . $backfile;

        $mode = (stat($backfile))[2] ||\
                print STDERR "Stat failed: $backfile: $!\n";
        printf "$backfile: %04o\n", $mode & 07777;
        chmod $mode, $backfile;
}

exit(0);

On Mon, 13 Dec 1999, Dan Horth wrote:

> ok - here's the scenario...
> 
> I stupidly managed to change all the files in my /etc/ directory to 
> 755 permissions (directories too) and now things are complaining and 
> I also think that this is not a very secure way for my /etc/ 
> directory to be...
> 
> I have a backup of this directory with all the correct permissions 
> set on another drive - but the files are a bit out of date.
> 
> I have kinda kludgily patched things up a bit by doing:
> 
> find -maxdepth 10 -type d | xargs chmod 755
> find -maxdepth 10 -type f | xargs chmod 644
> 
> but this is still not a perfect solution as files such as shadow, and 
> others should be set to custom permissions ....
> 
> -r--------   1 root     root         1292 Dec  8 09:30 shadow
> 
> what I was wondering is is someone able to help me string together a 
> command or script (shell is good - perl is more fun as I'm trying to 
> learn) that says this:




-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to