--- loncom/debugging_tools/dump_db.pl 2006/06/19 09:36:22 1.6 +++ loncom/debugging_tools/dump_db.pl 2007/07/25 17:43:34 1.8 @@ -4,7 +4,7 @@ # # dump_db.pl - dump a GDBM database to standard output, unescaping if asked to. # -# $Id: dump_db.pl,v 1.6 2006/06/19 09:36:22 www Exp $ +# $Id: dump_db.pl,v 1.8 2007/07/25 17:43:34 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,6 +36,8 @@ use Data::Dumper; use Storable qw(thaw); use lib '/home/httpd/lib/perl/'; use LONCAPA; +use LONCAPA::Configuration; +use Cwd; # # Options @@ -66,10 +68,20 @@ END exit; } +my %perlvar=%{&LONCAPA::Configuration::read_conf('loncapa.conf')}; + # # Loop through ARGV getting files. while (my $fname = shift) { - my $dbref=&LONCAPA::locking_hash_tie($fname,&GDBM_READER()); + $fname = &Cwd::abs_path($fname); + my $dbref; + if ($fname =~ m/^\Q$perlvar{'lonUsersDir'}\E/) { + $dbref=&LONCAPA::locking_hash_tie($fname,&GDBM_READER()); + } else { + if (tie(my %db,'GDBM_File',$fname,&GDBM_READER(),0640)) { + $dbref = \%db; + } + } if (!$dbref) { warn "Unable to tie to $fname"; @@ -88,7 +100,11 @@ while (my $fname = shift) { } print "$key = ".(ref($value)?Dumper($value):$value)."\n"; } - &LONCAPA::locking_hash_untie($dbref); + if ($fname =~ m/^\Q$perlvar{'lonUsersDir'}\E/) { + &LONCAPA::locking_hash_untie($dbref); + } else { + untie($dbref); + } } exit;