[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

RE: [TEKNIK] Vrøvl med ejerskaber



> > Poul Anker Gensmann wrote:
> > > Jeg har ved et uheld ændret ejer og gruppe på store dele af
> > > mit filsystem.
> > > Er der ikke en der vil ridse op hvem de forskellige dirs bør
> > > tilhøre eller henvise til et sted hvor det står?
>
> > Hvis det drejer som om filer der er installeret fra RPM'er er det
muligt
> > at uddrage informationen derfra.
>
Fremgangsmåden er følgende:

1) Uddrag den nødvendige information fra RPM-databasen
   og gem oplysningerne i filen rpminfo:

     rpm -qa --queryformat '[%{=NAME}\t%{FILEMODES}\t%{FILENAMES}\n]' >
rpminfo

2) Gendan filrettighederne udfra informationerne i rpminfo.

   Dette gøres ved at føde Perl-scriptet FixPermsToMatchRPM.pl
   med rpminfo og sende output ned i en logfil:

     FixPermsToMatchRPM.pl < rpminfo > rpmfixlog

Scriptet FixPermsToMatchRPM.pl er selvfølgelig kernen i det hele.
Scriptet ser ud som følger:

------------------- FixPermsToMatchRPM.pl --------------------

#!/usr/bin/perl -w

# Script to fix permissions on files in system to match those of RPM.
# Mads Dydensborg, 20000114.

$lastpackage = "";
$count = 0;
while(<>) {
    # Split the information in fields
    chop($_);
    ($rpmpackage, $rpmperm, $rpmfile) = split(/\t/, $_);
    # Check the package name, print if neccesary
    if ($lastpackage ne $rpmpackage) {
        print "COUNT SO FAR: $count\n";
        print "PACKAGE: $rpmpackage\n";
        $lastpackage = $rpmpackage;
    }
    # Adjust the permission to rigth value
    $rpmperm = $rpmperm & 4095;
    # Check in the hash if there are conflicts.
    if (defined $rpmfileperm{$rpmfile}
        && $rpmfileperm{$rpmfile} != $rpmperm) {
        printf "WARNING: $rpmfile permission %o differs from %o\n",
        $rpmfile, $rpmfileperm{$rpmfile};
    } else {
        # hash and apply
        $rpmfileperm{$rpmfile} = $rpmperm;
        if (-e $rpmfile) {
            $res = system(sprintf("chmod %o $rpmfile", $rpmperm));
            if (0 != $res) {
                print "WARNING: chmod $rpmperm $rpmfile (returned
error)\n";
            }
        } else {
            print "NOT PRESENT: $rpmfile does not exist\n";
        }
    }
    $count++;
}

------------------- FixPermsToMatchRPM.pl ----------------END-

/Martin
____________________________________
Systemadministrator - skydebanen.net
E-post: sslug@sslug
Web: http://www.skydebanen.net



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 21:38 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *