From f45d04e999b798f21ddcb887cf1bb9f3eb3a27b4 Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Thu, 23 Apr 2020 00:03:08 +0100 Subject: [PATCH] Fix unset/startup cmd --- cmd/unset/startup.pl | 6 +----- perl/Messages | 3 ++- perl/Msg.pm | 2 +- perl/Script.pm | 25 +++++++++++++++++++++++-- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/cmd/unset/startup.pl b/cmd/unset/startup.pl index 60efbda6..a08601c4 100644 --- a/cmd/unset/startup.pl +++ b/cmd/unset/startup.pl @@ -9,8 +9,4 @@ my ($self, $line) = @_; return (1, $self->msg('e5')) if $self->remotecmd || $self->inscript; return (1, $self->msg('e5')) if $line && $self->priv < 5; -my @out; - -Script::erase($line || $self->call); -push @out, $self->msg('done'); -return (1, @out); +return (1, Script::erase($self)); diff --git a/perl/Messages b/perl/Messages index 8d64f796..625fd5ee 100644 --- a/perl/Messages +++ b/perl/Messages @@ -206,8 +206,9 @@ package DXM; m17 => 'Sorry, cannot send messages in $_[0] mode', m18 => 'Sorry, message $_[0] is currently set to KEEP', m19 => 'Startup Script for $_[0] saved, $_[1] lines', - m20 => 'Empty Startup Script for $_[0] deleted', + m20 => 'Startup Script for $_[0] deleted', m21 => '$_[0] Working...', + m22 => 'Startup Script for $_[0] not found/error $!', maxconnect => 'Max connections on $_[0] set to $_[1]', msg1 => 'Bulletin Messages Queued', msg2 => 'Private Messages Queued', diff --git a/perl/Msg.pm b/perl/Msg.pm index 4400fe8d..3c4b51f3 100644 --- a/perl/Msg.pm +++ b/perl/Msg.pm @@ -279,7 +279,7 @@ sub disconnect if ($sock->{buffer}) { my $lth = length $sock->{buffer}; Mojo::IOLoop->timer($disc_waittime, sub { - dbg("Buffer contained $lth data , coordinated for $disc_waittime secs, now disconnecting $call") if $dbg; + dbg("Buffer contained $lth characters, coordinated for $disc_waittime secs, now disconnecting $call") if $dbg; _close_it($conn); }); } else { diff --git a/perl/Script.pm b/perl/Script.pm index 716ee46e..1e94ce59 100644 --- a/perl/Script.pm +++ b/perl/Script.pm @@ -22,7 +22,7 @@ my $base = "$main::root/scripts"; sub clean { my $s = shift; - $s =~ s/[^-\w\.]//g; + $s =~ s/([-\w\d_]+)/$1/g; return $s; } @@ -118,5 +118,26 @@ sub lines sub erase { my $self = shift; - unlink $self->{fn}; + my $call = clean($self->call); + + my $fn; + my $try; + + $try = "$base/" . clean(lc $self->call); + if (-w $try) { + $fn = $try; + } else { + $try = "$base/" . clean(uc $self->call); + if (-w $try) { + $fn = $try; + } + } + + if ($fn && -w $fn) { + unless (unlink $fn) { + return ($self->msg('m22'. $call)); + } + return ($self->msg('m20', $call)); + } + return ($self->msg('e3', "unset/startup", $call)); } -- 2.43.0