Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of rafael (2125)

Friday July 02, 2004
10:48 AM

Restoring perms

[ #19651 ]
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 :


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., the perl bindings to RPMs, are not backported to CPAN (-- yet).

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.