+17Feb99========================================================================
+1. added export_user.pl to export user files (for interest and safety)
+2. changed DXUser::init to allow O_RDONLY access which may limit the number
+of coredumps G0RDI seems to get.
15Feb99========================================================================
1. Added msg forwarding code which uses $main::root/msg/forward.pl.
14Feb99========================================================================
#
sub init
{
- my ($pkg, $fn) = @_;
+ my ($pkg, $fn, $mode) = @_;
confess "need a filename in User" if !$fn;
- $dbm = tie (%u, MLDBM, $fn, O_CREAT|O_RDWR, 0666) or confess "can't open user file: $fn ($!)";
+ if ($mode) {
+ $dbm = tie (%u, MLDBM, $fn, O_CREAT|O_RDWR, 0666) or confess "can't open user file: $fn ($!)";
+ } else {
+ $dbm = tie (%u, MLDBM, $fn, O_RDONLY) or confess "can't open user file: $fn ($!)";
+ }
+
$filename = $fn;
}
use Msg;
use DXVars;
use DXDebug;
-use DXUser;
use IO::File;
use IO::Socket;
use IPC::Open2;
}
+ use DXUser;
+
DXUser->init($userfn);
# allow a login from an existing user. I could create a user but
# initialise User file system
print "loading user file system ...\n";
-DXUser->init($userfn);
+DXUser->init($userfn, 1);
# start listening for incoming messages/connects
print "starting listener ...\n";
$ans = <STDIN>;
if ($ans =~ /^[Yy]/) {
delete_it();
- DXUser->init($userfn);
+ DXUser->init($userfn, 1);
create_it();
} else {
print "Do you wish to reset your cluster and sysop information? [y/N]: ";
$ans = <STDIN>;
if ($ans =~ /^[Yy]/) {
- DXUser->init($userfn);
+ DXUser->init($userfn, 1);
create_it();
}
}
} else {
- DXUser->init($userfn);
+ DXUser->init($userfn, 1);
create_it();
}
DXUser->finish();
--- /dev/null
+#!/usr/bin/perl
+#
+# Export the user file in a form that can be directly imported
+# back with a do statement
+#
+
+require 5.004;
+
+# search local then perl directories
+BEGIN {
+ # root of directory tree for this system
+ $root = "/spider";
+ $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
+
+ unshift @INC, "$root/perl"; # this IS the right way round!
+ unshift @INC, "$root/local";
+}
+
+use DXVars;
+use DXUser;
+
+$userfn = $ARGV[0] if @ARGV;
+
+DXUser->init($userfn);
+
+@all = DXUser::get_all_calls();
+$t = scalar time;
+print "#!/usr/bin/perl
+#
+# The exported userfile for a DXSpider System
+#
+# Input file: $userfn
+# Time: $t
+#
+
+package DXUser;
+
+%u = (
+";
+
+for $a (@all) {
+ my $ref = DXUser->get($a);
+ print "'$a' => bless ( { ";
+
+ my $f;
+ for $f (sort keys %{$ref}) {
+ my $val = ${$ref}{$f};
+ $val =~ s/'/\\'/og;
+ print "'$f' => '$val', ";
+ }
+ print " }, 'DXUser'),\n";
+ $count++;
+}
+print ");\n
+#
+# there were $count records
+#\n";
+