added spoofing
authordjk <djk>
Mon, 8 Nov 1999 13:11:05 +0000 (13:11 +0000)
committerdjk <djk>
Mon, 8 Nov 1999 13:11:05 +0000 (13:11 +0000)
detail changes to db stuff

Changes
cmd/dbgetkey.pl [deleted file]
cmd/dbimport.pl
cmd/dbshow.pl [new file with mode: 0644]
cmd/dbstatus.pl [new file with mode: 0644]
cmd/spoof.pl [new file with mode: 0644]
perl/DXCommandmode.pm
perl/DXDb.pm
perl/Messages

diff --git a/Changes b/Changes
index 19f517d7cc7e5cef63d21c35128bd8bdcd90e416..9e06872d2c4933f6c154e0a6059f470be5da5421 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+08Nov99=======================================================================
+1. added spoofing (mk1 version) for sysops, useful for those little jobs like
+reseting a user's qra locator and such like "spoof g7brn set/qra jo02lq".
 07Nov99=======================================================================
 1. reduced the amount of stuff compared against for dup announces.
 2. Check the regex for DK0WCY announces produces results before storing it as
diff --git a/cmd/dbgetkey.pl b/cmd/dbgetkey.pl
deleted file mode 100644 (file)
index f48def4..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/perl
-#
-# Database update routine
-#
-# Copyright (c) 1999 Dirk Koopman G1TLH
-#
-my ($self, $line) = @_;
-my @f = split /\s+/, $line;
-my @out;
-
-my $name = shift @f if @f;
-my $db = DXDb::getdesc($name);
-return (1, $self->msg('db3', $name)) unless $db;
-
-if ($db->remote) {
-       for (@f) {
-               my $n = DXDb::newstream($self->call);
-               DXProt::route(undef, $db->remote, DXProt::pc44($main::mycall, $db->remote, $n, uc $db->name,uc $_, $self->call));
-       }
-} else {
-       for (@f) {
-               my $value = $db->getkey($_);
-               if ($value) {
-                       push @out, split /\n/, $value;
-               } else {
-                       push @out, $self->msg('db2', $_, $db->{name});
-               }
-       }
-}
-
-return (1, @out);
index 55d5e6322c00c4975e7387f90f2ca02e89781049..797805eaee2d7513246b81d88b303ad4430c94a0 100644 (file)
@@ -31,14 +31,18 @@ while (<IMP>) {
                }
                $key = uc $_;
                $value = undef;
-               ++$state;
+               ++$state if $key;
        } elsif ($state == 1) {
                if (/^\&\&/) {
                        if ($key =~ /^#/) {
+                       } elsif ($key && $value) {
+                               $db->putkey($key, $value);
+                               $count++;
                        }
-                       $db->putkey($key, $value);
                        $state = 0;
-                       $count++;
+                       next;
+               } elsif (/^\%\%/) {
+                       $state = 0;
                        next;
                }
                $value .= $_ . "\n";
diff --git a/cmd/dbshow.pl b/cmd/dbshow.pl
new file mode 100644 (file)
index 0000000..f48def4
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+#
+# Database update routine
+#
+# Copyright (c) 1999 Dirk Koopman G1TLH
+#
+my ($self, $line) = @_;
+my @f = split /\s+/, $line;
+my @out;
+
+my $name = shift @f if @f;
+my $db = DXDb::getdesc($name);
+return (1, $self->msg('db3', $name)) unless $db;
+
+if ($db->remote) {
+       for (@f) {
+               my $n = DXDb::newstream($self->call);
+               DXProt::route(undef, $db->remote, DXProt::pc44($main::mycall, $db->remote, $n, uc $db->name,uc $_, $self->call));
+       }
+} else {
+       for (@f) {
+               my $value = $db->getkey($_);
+               if ($value) {
+                       push @out, split /\n/, $value;
+               } else {
+                       push @out, $self->msg('db2', $_, $db->{name});
+               }
+       }
+}
+
+return (1, @out);
diff --git a/cmd/dbstatus.pl b/cmd/dbstatus.pl
new file mode 100644 (file)
index 0000000..34198bf
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+#
+# Database update routine
+#
+# Copyright (c) 1999 Dirk Koopman G1TLH
+#
+my ($self, $line) = @_;
+my @f = split /\s+/, $line;
+my @out;
+
+
+return (1, @out);
diff --git a/cmd/spoof.pl b/cmd/spoof.pl
new file mode 100644 (file)
index 0000000..8c8fda8
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+#
+# pretend that you are another user, useful for reseting
+# those silly things that people insist on getting wrong
+# like set/homenode et al
+#
+# Copyright (c) 1999 Dirk Koopman G1TLH
+#
+my ($self, $line) = @_;
+
+my $mycall = $self->call;
+my $myuser = $self->user;
+
+my ($call, $newline) = split /\s+/, $line, 2;
+return (1, $self->msg('nodee1', $call)) if DXChannel->get($call);
+
+if ($self->remotecmd) {
+       Log('DXCommand', "$mycall is trying to spoof $call remotely");
+       return (1, $self->msg('e5'));
+}
+if ($self->priv < 9) {
+       Log('DXCommand', "$mycall is trying to spoof $call locally");
+       return (1, $self->msg('e5'));
+}
+
+my @out;
+$call = uc $call;
+my $user = DXUser->get($call);
+unless ($user) {
+       $user = DXUser->new($call);
+       push @out, $self->msg('spf1', $call);
+}
+
+# set up basic environment
+$self->call($call);
+$self->user($user);
+Log('DXCommand', "spoof '$newline' as $call by $mycall");
+my @in = $self->run_cmd($newline);
+push @out, map {"spoof $call: $_"} @in;
+$self->call($mycall);
+$self->user($myuser);
+
+return (1, @out);
index 13286cc5f706f0501be05f6f84c09c7fc33df648..5439fc4d21bcc8cfee490cb541ba19551e83f660 100644 (file)
@@ -206,7 +206,8 @@ sub run_cmd
                $cmdline =~ s|//|/|og;
                
                # split the command line up into parts, the first part is the command
-               my ($cmd, $args) = $cmdline =~ /^([\S\/]+)\s*(.*)/o;
+               my ($cmd, $args) = split /\s+/, $cmdline, 2;
+               $args = "" unless $args;
                
                if ($cmd) {
                        
@@ -217,7 +218,8 @@ sub run_cmd
                        # alias it if possible
                        my $acmd = CmdAlias::get_cmd($cmd);
                        if ($acmd) {
-                               ($cmd, $args) = "$acmd $args" =~ /^([\w\/]+)\s*(.*)/o;
+                               ($cmd, $args) = split /\s+/, "$acmd $args", 2;
+                               $args = "" unless $args;
                                dbg('command', "aliased cmd: $cmd $args");
                        }
                        
index 49da69c9804b729aad3cd04c87e7a4165397c395..ab37f85291010d3ab951336a6a8d8b93dd1329af 100644 (file)
@@ -258,7 +258,7 @@ sub process
                        my $n = getstream($f[3]);
                        if ($n) {
                                my $mchan = DXChannel->get($n->{call});
-                               $mchan->send($f[2] . ":$f[4]");
+                               $mchan->send($f[2] . ":$f[4]") if $mchan;
                        }
                        last SWITCH;
                }
index f0932783ebc673e264a4cdfc133558a2ce47b4eb..ab524d3b6ebede113a438b6348c9060a8631b0a0 100644 (file)
@@ -135,6 +135,7 @@ package DXM;
                                sloc => 'Cluster lat $_[0] long $_[1], DON\'T FORGET TO CHANGE YOUR DXVars.pm',
                                sqra => 'Cluster QRA Locator$_[0], DON\'T FORGET TO CHANGE YOUR DXVars.pm',
                                sorry => 'Sorry',
+                               spf1 => 'spoof: creating new user $_[0]',
                                suser1 => 'usage: callsign user_field_name value',
                                suser2 => 'User $_[0] not found',
                                suser3 => 'User field \'$_[0]\' was \'$_[1]\' now set to \'$_[2]\'',