Novell NSS volumes mounted in Linux offer a great benefit for backup/restore by exposing their assigned trustees and inherited rights masks (IRM) in a XML file inside the Volume. If you take a look inside the .NETWARE directory on the mountpoint, you'll see a file called .trusteedatabase.xml. If your backup plan includes this file, recovery of trustees and IRM is an easy task which can be accomplished with this script I wrote.
#!/usr/bin/perl -w
# Copyright (c) 2008 Michael Fladischer, Austria.
# All rights reserved.
#
# Author: Michael Fladischer , 2008
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GPL.
use Getopt::Std;
use XML::XPath;
use vars qw/ %opt /;
sub init()
{
use Getopt::Std;
getopts( 'hvp:m:', \%opt ) or usage();
usage() if $opt{h} or !$opt{m} or !$opt{p};
}
sub usage()
{
print STDERR << "EOF";
This program is free software; you can redistribute it and/or modify it
under the terms of the GPL.
Restore trustees and inherited rights masks from XML.
usage: $0 [-hvd] -m mountpoint -p pattern
-h : this (help) message
-v : verbose output
-m mountpoint : mountpoint of NSS volume
-p pattern : path to match
example: $0 -v -m /media/nss/VOLUME -p /users
EOF
exit;
}
init();
my $xp = XML::XPath->new(filename => $opt{m}.
"/._NETWARE/.trustee_database.xml");
foreach my $trustee ($xp->find(
"/volume_trustees/trustee[starts-with(\@path,'".
$opt{p}."')]")->get_nodelist) {
if ($opt{v}) {
print "Restore trustee for ".
$opt{m}.$trustee->find('@path')."\n";
print " ".$trustee->find('name')->string_value." -> ".
$trustee->find('rights')->string_value."\n";
}
system("ncpcon rights add ".$opt{m}.$trustee->find('@path').
" ".substr($trustee->find('name')->string_value, 1).
" ".$trustee->find('rights')->string_value." &>/dev/null");
}
foreach my $irm ($xp->find(
"/volume_trustees/inherited_rights_mask[starts-with(\@path,'".
$opt{p}."')]")->get_nodelist) {
if ($opt{v}) {
print "Restore inherited rights mask for ".
$opt{m}.$irm->find('@path')."\n";
print " ".$irm->find('rights')->string_value."\n";
}
system("ncpcon irm set ".$opt{m}.$irm->find('@path').
" ".$irm->find('rights')->string_value." &>/dev/null");
}
Add a comment