mega-merge of major parts of mojo
[spider.git] / cmd / spoof.pl
1 #!/usr/bin/perl
2 #
3 # pretend that you are another user, useful for reseting
4 # those silly things that people insist on getting wrong
5 # like set/homenode et al
6 #
7 # Copyright (c) 1999 Dirk Koopman G1TLH
8 #
9 my ($self, $line) = @_;
10
11 my $mycall = $self->call;
12 my $myuser = $self->user;
13 my $mylang = $self->lang;
14
15 my ($call, $newline) = split /\s+/, $line, 2;
16 return (1, $self->msg('nodee1', $call)) if DXChannel::get($call);
17
18 if ($self->remotecmd || $self->inscript) {
19         Log('DXCommand', "$mycall is trying to spoof $call remotely");
20         return (1, $self->msg('e5'));
21 }
22 if ($self->priv < 9) {
23         Log('DXCommand', "$mycall is trying to spoof $call locally");
24         return (1, $self->msg('e5'));
25 }
26
27 my @out;
28 $call = uc $call;
29 my $user = DXUser::get_current($call);
30 unless ($user) {
31         $user = DXUser->new($call);
32         push @out, $self->msg('spf1', $call);
33 }
34
35 # set up basic environment
36 $self->call($call);
37 $self->user($user);
38 my $addr = $self->hostname || '127.0.0.1';
39 Log('cmd', "$self->{call}|$addr|spoof|$line");
40 my @in = $self->run_cmd($newline);
41 push @out, map {"spoof $call: $_"} @in;
42 $self->call($mycall);
43 $self->user($myuser);
44 $self->lang($mylang);
45
46 return (1, @out);