Restoring perms

rafael on 2004-07-02T15:48:17

And so there was this guy who performed a chmod -R 770 /. That's funny, but what to do when you have to repair the machine ? You can extract all the original permissions from the RPM database :

#!/usr/bin/perl

use strict; use URPM;

URPM::DB::open()->traverse(sub { my ($package) = @_; my $name = $package->fullname; my @modes = $package->files_mode; printf "$name:$_:%04o\n",(shift @modes) & 07777 for $package->files; });


At least this works on a Mandrakelinux system. URPM.pm, the perl bindings to RPMs, are not backported to CPAN (-- yet).


number of lines.

jdavidboyd on 2004-07-03T17:19:49

When I run this on my Mandrake Linux 10 box, it comes back with 172386 lines of permissions.

Hope you are taking this the next step and automating the setting of these permissions.

It would take quite a long time to do them manually...

Re:number of lines.

rafael on 2004-07-03T21:56:06

This is left as an exercise to the reader :)

Re:number of lines.

jdavidboyd on 2004-07-05T15:25:00

Ah,
Good thing I don't need any exercise!