Commit 339646a2 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add a file attributes section to the XML file that is created for each

run, to store the original attributes, owner, group, and mtime/ctime/atime.
parent 2fcaa3e3
......@@ -11,6 +11,8 @@ use POSIX qw(isatty setsid);
use POSIX qw(strftime);
use Errno qw(EDQUOT ETIMEDOUT);
use XML::Simple;
use File::Find;
use File::stat;
use Data::Dumper;
#
......@@ -1082,6 +1084,30 @@ sub CheckForDeadNodes($)
}
}
#
# Callback to generate the file listing.
#
my @allfiles = ();
sub FindCallBack
{
my $name = $_;
return
if ($name eq "." || $name eq "..");
my $st = stat($name) or
fatal(-1, "Failed to stat $name!");
push(@allfiles, {'pathname' => "$File::Find::dir/$name",
'mode' => $st->mode,
'uid' => $st->uid,
'gid' => $st->gid,
'atime' => $st->atime,
'mtime' => $st->mtime,
'ctime' => $st->ctime});
}
#
# Generate an XML file describing the just finished run.
#
......@@ -1135,6 +1161,20 @@ sub GenXML($$)
}
}
# File listing to preserve attributes, just in case.
my $cwd = `/bin/pwd`;
# Must do the taint check too.
if ($cwd =~ /^(.*)$/) {
$cwd = $1;
}
if (! chdir($instance->path())) {
print STDERR "*** Could not chdir to instance path\n";
return -1;
}
find({'wanted' => \&FindCallBack, 'untaint' => 1}, ".");
chdir($cwd);
$root->{"files"} = {"file" => [@allfiles]};
if ($debug) {
print Dumper($root);
print "\n";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment