From ba0bc47c95759a369af81fb19556c48261530a79 Mon Sep 17 00:00:00 2001 From: minima Date: Fri, 2 Nov 2001 18:50:18 +0000 Subject: [PATCH] Fixed some Aliasing problems. Changed the talk logging. Changed the email of personal messages to use Net::SMTP. Tidied up Expunging. --- Changes | 28 +++++++++--- cmd/Aliases | 37 +++++++++------- cmd/export.pl | 2 +- cmd/msg.pl | 5 +++ cmd/read.pl | 2 +- perl/DXCommandmode.pm | 12 +++-- perl/DXMsg.pm | 100 ++++++++++++++++++++++++++++++------------ perl/DXProt.pm | 2 +- perl/DXUser.pm | 2 +- 9 files changed, 134 insertions(+), 56 deletions(-) diff --git a/Changes b/Changes index b0acc50d..a16c7ca3 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,27 @@ +02Nov01======================================================================= +1. fixed some Aliasing problems, but this whole area will have to be addressed +more comprehensively. +2. Changed talk logging so that it hopefully is more consistant and maybe even +useful. +3. Altered the mechanism of the personal emailing so that it uses lower level +components and should be therefore available on M$ platforms. You will need +to install a version of libnet (perl -MCPAN -eshell, then install Net::SMTP). +I believe all 5.6.x perls have this built in (ie M$ should have this). If you +are on M$ or you want to use an MTA via SMTP in linux then you need to declare +the dns name of the MTA by: set/var $DXMsg::email_server = 'post.fred.net' +(or whatever the MTA is called). You can also use local programs other than +sendmail by: set/var $DXMsg::email_prog = '/usr/bin/postfix ..' or whatever. +Finally you can alter the 'from' address using: set/var $DXMsg::email_from += 'FBloggs@msn.com' (\@ if you use " and ") - bewarned that you may be +prevented from using just any old address. You can place these commands in +/spider/scripts/startup for permanent use. 01Nov01======================================================================= 1. added information on registration, login scripts and passwords to the -administration manual +26Oct01======================================================================= +1. If $main::reqreg = 1 then set/register will allow 'registered' users +full access, if $main::reqreg = 2 then registered users will be 'read-only' +(ie the opposite). If $main::reqreg = 0 then registration and its effects +are disabled. 25Oct01======================================================================= 1. added unset/password command to allow sysops (only) to completely delete and remove a user's password. @@ -8,10 +29,7 @@ and remove a user's password. 3. give a read receipt for everybody that reads a message so marked. 4. enhance set/email so that if you set email address(es) with this command it will send any messages to your callsign as they come in. unset/email -will disable forwarding. This probably only works for unix systems. To enable -this feature you need to download Mail::Send from CPAN and install it. -(http://www.cpan.org/modules/by-module/Mail/MailTools-1.40.tar.gz). If you -don't want this then it should work without. +will disable forwarding. 24Oct01======================================================================= 1. added (un)set/register, show/registered commands which when a 'set/var $main::reqreg = 1' is done in the startup script will require users to diff --git a/cmd/Aliases b/cmd/Aliases index 7f11aa90..f956c14f 100644 --- a/cmd/Aliases +++ b/cmd/Aliases @@ -27,9 +27,9 @@ package CmdAlias; ], 'a' => [ '^acc?e?p?t?$', 'apropos accept', 'apropos', - '^ann\w*/full', 'announce full', 'announce', - '^ann\w*/sysop', 'announce sysop', 'announce', - '^ann\w*/(.*)$', 'announce $1', 'announce', + '^ann?o?u?n?c?e?/full', 'announce full', 'announce', + '^ann?o?u?n?c?e?/sysop', 'announce sysop', 'announce', + '^ann?o?u?n?c?e?/(.*)$', 'announce $1', 'announce', ], 'b' => [ '^b$', 'bye', 'bye', @@ -39,22 +39,24 @@ package CmdAlias; '^cre?a?t?e?$', 'apropos create', 'apropos', ], 'd' => [ - '^del\w*/u', 'delete/user', 'delete/user', - '^del\w*/fu', 'kill full', 'kill', - '^del', 'kill', 'kill', - '^di\w*/a\w*', 'directory all', 'directory', - '^di\w*/b\w*', 'directory bulletins', 'directory', - '^di\w*/n\w*', 'directory new', 'directory', - '^di\w*/o\w*', 'directory own', 'directory', - '^di\w*/s\w*', 'directory subject', 'directory', - '^di\w*/t\w*', 'directory to', 'directory', - '^di\w*/f\w*', 'directory from', 'directory', - '^di\w*/(\d+)-(\d+)', 'directory $1-$2', 'directory', - '^di\w*/(\d+)', 'directory $1', 'directory', + '^dele?t?e?/u', 'delete/user', 'delete/user', + '^dele?t?e?/fu', 'kill full', 'kill', + '^dele?t?e?$', 'kill', 'kill', + '^dir?e?c?t?o?r?y?/a\w*', 'directory all', 'directory', + '^dir?e?c?t?o?r?y?/b\w*', 'directory bulletins', 'directory', + '^dir?e?c?t?o?r?y?/n\w*', 'directory new', 'directory', + '^dir?e?c?t?o?r?y?/o\w*', 'directory own', 'directory', + '^dir?e?c?t?o?r?y?/s\w*', 'directory subject', 'directory', + '^dir?e?c?t?o?r?y?/t\w*', 'directory to', 'directory', + '^dir?e?c?t?o?r?y?/f\w*', 'directory from', 'directory', + '^dir?e?c?t?o?r?y?/(\d+)-(\d+)', 'directory $1-$2', 'directory', + '^dir?e?c?t?o?r?y?/(\d+)', 'directory $1', 'directory', ], 'e' => [ '^exi?t?$', 'bye', 'bye', - '^exp?u?\w+$', 'kill expunge', 'kill expunge', + '^export_u', 'export_users', 'export_users', + '^expor?', 'export', 'export', + '^expun?g?e?$', 'kill expunge', 'kill expunge', ], 'f' => [ '^fo\w*$', 'apropos forward', 'apropos', @@ -68,6 +70,7 @@ package CmdAlias; 'j' => [ ], 'k' => [ + '^ki?l?l?/ex', 'kill expunge', 'kill', ], 'l' => [ '^loa?d?$', 'apropos load', 'apropos', @@ -119,8 +122,8 @@ package CmdAlias; '^sho?w?/up', 'show/cluster', 'show/cluster', '^sho?w?/ww?v?/(\d+)-(\d+)', 'show/wwv $1-$2', 'show/wwv', '^sho?w?/ww?v?/(\d+)', 'show/wwv $1', 'show/wwv', - '^shut?d?\w*$', 'shutdown', 'shutdown', '^sho?w?$', 'apropos show', 'apropos', + '^shut?d?\w*$', 'shutdown', 'shutdown', '^sp$', 'send', 'send', '^sta?t?$', 'apropos stat', 'apropos', diff --git a/cmd/export.pl b/cmd/export.pl index 4616564f..0e803a2f 100644 --- a/cmd/export.pl +++ b/cmd/export.pl @@ -47,7 +47,7 @@ if ($fh) { $m = $self->msg('export2', $msgno, $fn, $!, $self->call); } Log('msg', $m); -dbg('msg', $m); +dbg($m) if isdbg('msg'); push @out, $m; return (1, @out); diff --git a/cmd/msg.pl b/cmd/msg.pl index a1a3df06..93a10133 100644 --- a/cmd/msg.pl +++ b/cmd/msg.pl @@ -89,6 +89,11 @@ if ($cmd =~ /^to/i) { $old = $ref->keep ? 'Keep' : 'No Keep'; $new = 'No Keep'; $ref->keep(0); +} elsif ($cmd =~ /^node/i) { + $m = 'Delete'; + $old = $ref->delete ? 'Delete' : 'Not Delete'; + $new = 'Not Delete'; + $ref->unmark_delete; } elsif ($cmd =~ /^su/i) { $m = 'Subject'; $old = $ref->subject; diff --git a/cmd/read.pl b/cmd/read.pl index 1845b4d1..0056530a 100644 --- a/cmd/read.pl +++ b/cmd/read.pl @@ -17,7 +17,7 @@ my $ref; # that I haven't read yet if (@f == 0) { foreach $ref (DXMsg::get_all()) { - if ($ref->to eq $self->call && $ref->private && !$ref->read) { + if ($ref->to eq $self->call && $ref->private && !$ref->read && !$ref->delete) { push @f, $ref->msgno; last; } diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index c01085a5..6efd8cee 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -106,8 +106,10 @@ sub start $self->{here} = 1; # sort out registration - if ($main::reqreg) { + if ($main::reqreg == 1) { $self->{registered} = $user->registered; + } elsif ($main::reqreg == 2) { + $self->{registered} = !$user->registered; } else { $self->{registered} = 1; } @@ -284,7 +286,11 @@ sub normal } else { eval { @ans = &{$self->{func}}($self, $cmdline) }; } - $self->send_ans("Syserr: on stored func $self->{func}", $@) if $@; + if ($@) { + $self->send_ans("Syserr: on stored func $self->{func}", $@); + $self->state('prompt'); + undef $@; + } $self->send_ans(@ans); } else { $self->send_ans(run_cmd($self, $cmdline)); @@ -717,7 +723,7 @@ sub talk my ($self, $from, $to, $via, $line) = @_; $line =~ s/\\5E/\^/g; $self->local_send('T', "$to de $from: $line") if $self->{talk}; - Log('talk', $to, $from, $main::mycall, $line); + Log('talk', $to, $from, $via?$via:$main::mycall, $line); # send a 'not here' message if required unless ($self->{here} && $from ne $to) { my $key = "$to$from"; diff --git a/perl/DXMsg.pm b/perl/DXMsg.pm index 3038b756..118feef4 100644 --- a/perl/DXMsg.pm +++ b/perl/DXMsg.pm @@ -27,7 +27,7 @@ use IO::File; use Fcntl; eval { - require Mail::Send; + require Net::SMTP; }; use strict; @@ -40,6 +40,7 @@ $main::branch += $BRANCH; use vars qw(%work @msg $msgdir %valid %busy $maxage $last_clean $residencetime @badmsg @swop $swopfn $badmsgfn $forwardfn @forward $timeout $waittime + $email_server $email_prog $email_from $queueinterval $lastq $importfn $minchunk $maxchunk $bulltopriv); %work = (); # outstanding jobs @@ -60,7 +61,9 @@ $minchunk = 4800; # minimum chunk size for a split message $maxchunk = 6000; # maximum chunk size $bulltopriv = 1; # convert msgs with callsigns to private if they are bulls $residencetime = 2*86400; # keep deleted messages for this amount of time - +$email_server = undef; # DNS address of smtp server if 'smtp' +$email_prog = undef; # program name + args for sending mail +$email_from = undef; # the from address the email will appear to be from $badmsgfn = "$msgdir/badmsg.pl"; # list of TO address we wont store $forwardfn = "$msgdir/forward.pl"; # the forwarding table @@ -95,6 +98,14 @@ $importfn = "$msgdir/import"; # import directory deletetime => '5,Deletion Time,cldatetime', ); +# fix up the default sendmail if available +for (qw(/usr/sbin/sendmail /usr/lib/sendmail /usr/sbin/sendmail)) { + if (-e $_) { + $email_prog = $_; + last; + } +} + # allocate a new object # called fromnode, tonode, from, to, datetime, private?, subject, nolinesper sub alloc @@ -106,7 +117,6 @@ sub alloc # $to =~ s/-\d+$//o; $self->{to} = ($to eq $main::mycall) ? $main::myalias : $to; my $from = shift; - $from =~ s/-\d+$//o; $self->{from} = uc $from; $self->{t} = shift; $self->{private} = shift; @@ -427,23 +437,40 @@ sub notify my $to = $ref->{to}; my $uref = DXUser->get($to); my $dxchan = DXChannel->get($to); - if (*Mail::Send && $uref && $uref->wantemail) { + if (((*Net::SMTP && $email_server) || $email_prog) && $uref && $uref->wantemail) { my $email = $uref->email; if ($email) { - my @list = ref $email ? @{$email} : $email; - my $msg = new Mail::Send Subject=>"[DXSpider: $ref->{from}] $ref->{subject}"; - $msg->to(@list); - my $fh = $msg->open; - if ($fh) { - print $fh "From: $ref->{from} To: $to On Node: $main::mycall Origin: $ref->{origin} Msgno: $ref->{msgno}\r\n\r\n"; - print $fh map {"$_\r\n"} $ref->read_msg_body; - $fh->close; - for (@list) { - Log('msg', "Msgno $ref->{msgno} from $ref->{from} emailed to $_"); + my @rcpt = ref $email ? @{$email} : $email; + my $fromaddr = $email_from || $main::myemail; + my @headers = ("To: $ref->{to}", + "From: $fromaddr", + "Subject: [DXSpider: $ref->{from}] $ref->{subject}", + "X-DXSpider-To: $ref->{to}", + "X-DXSpider-From: $ref->{from}\@$ref->{origin}", + "X-DXSpider-Gateway: $main::mycall" + ); + my @data = ("Msgno: $ref->{msgno} To: $to From: $ref->{from}\@$ref->{origin} Gateway: $main::mycall", + "", + $ref->read_msg_body + ); + my $msg; + undef $!; + if (*Net::SMTP && $email_server) { + $msg = Net::SMTP->new($email_server); + if ($msg) { + $msg->mail($fromaddr); + $msg->to(@rcpt); + $msg->data(map {"$_\n"} @headers, '', @data); + $msg->quit; + } + } elsif ($email_prog) { + $msg = new IO::File "|$email_prog " . join(' ', @rcpt); + if ($msg) { + print $msg map {"$_\r\n"} @headers, '', @data, '.'; + $msg->close; } - } else { - dbg("email forwarding error $!") if isdbg('msg'); } + dbg("email forwarding error $!") if isdbg('msg') && !$msg && defined $!; } } $dxchan->send($dxchan->msg('m9')) if $dxchan && $dxchan->is_user; @@ -501,6 +528,14 @@ sub store confess "can't open msg file $fn $!"; } } + + # actual remove all the 'deleted' messages in one hit. + # this has to me delayed until here otherwise it only does one at + # a time because @msg is rewritten everytime del_msg is called. + my @del = grep {!$_->{tonode} && $_->{delete} && $_->{deletetime} < $main::systime} @msg; + for (@del) { + $_->del_msg; + } } # delete a message @@ -508,17 +543,19 @@ sub del_msg { my $self = shift; my $dxchan = shift; + my $call = ''; + $call = ' by ' . $dxchan->call if $dxchan; if ($self->{tonode}) { $self->{delete}++; $self->{deletetime} = 0; + dbg("Msgno $self->{msgno} but marked as expunged$call") if isdbg('msg'); } else { # remove it from the active message list @msg = grep { $_ != $self } @msg; - my $call = ''; - $call = ' by ' . $dxchan->call if $dxchan; Log('msg', "Msgno $self->{msgno} expunged$call"); + dbg("Msgno $self->{msgno} expunged$call") if isdbg('msg'); # remove the file unlink filename($self->{msgno}); @@ -536,6 +573,14 @@ sub mark_delete $ref->store( [$ref->read_msg_body] ); } +sub unmark_delete +{ + my $ref = shift; + my $t = shift; + delete $ref->{delete}; + delete $ref->{deletetime}; +} + # clean out old messages from the message queue sub clean_old { @@ -687,10 +732,6 @@ sub queue_msg next if $ref->{tonode}; # ignore it if it already being processed # is it awaiting deletion? - if ($ref->{delete} && $main::systime >= $ref->{deletetime}) { - $ref->del_msg; - next; - } next if $ref->{delete}; # firstly, is it private and unread? if so can I find the recipient @@ -738,6 +779,8 @@ sub queue_msg # if all the available nodes are busy then stop last if @nodelist == scalar grep { get_busy($_->call) } @nodelist; } + + } # is there a message for me? @@ -1060,11 +1103,14 @@ sub do_send_stuff sub dir { my $ref = shift; - my $flag = $ref->read ? '-' : ' '; - $flag = 'D' if $ref->delete; - return sprintf "%6d%s%s%5d %8.8s %8.8s %-6.6s %5.5s %-30.30s", - $ref->msgno, $flag, $ref->private ? 'p' : ' ', $ref->size, - $ref->to, $ref->from, cldate($ref->t), ztime($ref->t), $ref->subject; + my $flag = $ref->{private} && $ref->{read} ? '-' : ' '; + if ($ref->{delete}) { + $flag = $ref->{deletetime} > $main::systime ? 'D' : 'E'; + } + return sprintf("%6d%s%s%5d %8.8s %8.8s %-6.6s %5.5s %-30.30s", + $ref->{msgno}, $flag, $ref->{private} ? 'p' : ' ', + $ref->{size}, $ref->{to}, $ref->{from}, cldate($ref->{t}), + ztime($ref->{t}), $ref->{subject}); } # load the forward table diff --git a/perl/DXProt.pm b/perl/DXProt.pm index 411b33b4..ee9c92f1 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -1774,7 +1774,7 @@ sub talk $line =~ s/\^/\\5E/g; # remove any ^ characters $self->send(DXProt::pc10($from, $to, $via, $line, $origin)); - Log('talk', $self->call, $from, $via?$via:$main::mycall, $line) unless $origin && $origin ne $main::mycall; + Log('talk', $to, $from, $via?$via:$self->call, $line) unless $origin && $origin ne $main::mycall; } # send it if it isn't the except list and isn't isolated and still has a hop count diff --git a/perl/DXUser.pm b/perl/DXUser.pm index 26c3f5db..47ebcdb0 100644 --- a/perl/DXUser.pm +++ b/perl/DXUser.pm @@ -40,7 +40,7 @@ $lasttime = 0; lat => '0,Latitude,slat', long => '0,Longitude,slong', qra => '0,Locator', - email => '0,E-mail Address', + email => '0,E-mail Address,parray', priv => '9,Privilege Level', lastin => '0,Last Time in,cldatetime', passwd => '9,Password,yesno', -- 2.43.0