projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix stupid unpad typo in dx command
[spider.git]
/
perl
/
DXCommandmode.pm
diff --git
a/perl/DXCommandmode.pm
b/perl/DXCommandmode.pm
index 46d2b1d38bd4d450f0f95b0fbda2e7b37281f274..d1feb3e18eb2e6dea892108a3eb15d2a8977d81f 100644
(file)
--- a/
perl/DXCommandmode.pm
+++ b/
perl/DXCommandmode.pm
@@
-50,6
+50,7
@@
use DXCIDR;
use strict;
use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase %nothereslug
$maxbadcount $msgpolltime $default_pagelth $cmdimportdir $users $maxusers
use strict;
use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase %nothereslug
$maxbadcount $msgpolltime $default_pagelth $cmdimportdir $users $maxusers
+ $maxcmdlth
);
%Cache = (); # cache of dynamically loaded routine's mod times
);
%Cache = (); # cache of dynamically loaded routine's mod times
@@
-64,6
+65,8
@@
$cmdimportdir = "$main::root/cmd_import"; # the base directory for importing com
$users = 0; # no of users on this node currently
$maxusers = 0; # max no users on this node for this run
$users = 0; # no of users on this node currently
$maxusers = 0; # max no users on this node for this run
+$maxcmdlth = 512; # max length of incoming cmd line (including the command and any arguments
+
#
# obtain a new connection this is derived from dxchannel
#
#
# obtain a new connection this is derived from dxchannel
#
@@
-249,6
+252,7
@@
sub start
}
$self->lastmsgpoll($main::systime);
}
$self->lastmsgpoll($main::systime);
+ $self->{user_interval} = $self->user->user_interval || $main::user_interval; # allow user to change idle time between prompts
$self->prompt;
}
$self->prompt;
}
@@
-534,15
+538,15
@@
sub run_cmd
if ($cmd) {
if ($cmd) {
- # check cmd
- if ($cmd =~ m|^/| || $cmd =~ m|[^-?\w/]|) {
+ # strip out // on command only
+ $cmd =~ s|//+|/|g;
+
+ # check for length of whole command line and any invalid characters
+ if (length $cmdline > $maxcmdlth || $cmd =~ m|\.| || $cmd !~ m|^\w+(?:/\w+){0,1}(?:/\d+)?$|) {
LogDbg('DXCommand', "cmd: $self->{call} - invalid characters in '$cmd'");
LogDbg('DXCommand', "cmd: $self->{call} - invalid characters in '$cmd'");
- return $self->_error_out('e
1
');
+ return $self->_error_out('e
40
');
}
}
- # strip out // on command only
- $cmd =~ s|//|/|g;
-
my ($path, $fcmd);
dbg("cmd: $cmd") if isdbg('command');
my ($path, $fcmd);
dbg("cmd: $cmd") if isdbg('command');
@@
-585,7
+589,7
@@
sub run_cmd
return $self->_error_out('e1');
}
} else {
return $self->_error_out('e1');
}
} else {
-
dbg("cmd: $cmd not found") if isdbg('command'
);
+
LogDbg('DXCommand', "$self->{call} cmd: '$cmd' not found"
);
return $self->_error_out('e1');
}
}
return $self->_error_out('e1');
}
}
@@
-594,11
+598,11
@@
sub run_cmd
if ($ok) {
delete $self->{errors};
} else {
if ($ok) {
delete $self->{errors};
} else {
- if (++$self->{errors} > $DXChannel::maxerrors) {
+ if (
$self != $main::me &&
++$self->{errors} > $DXChannel::maxerrors) {
$self->send($self->msg('e26'));
$self->disconnect;
return ();
$self->send($self->msg('e26'));
$self->disconnect;
return ();
- }
+ }
}
return map {s/([^\s])\s+$/$1/; $_} @ans;
}
}
return map {s/([^\s])\s+$/$1/; $_} @ans;
}
@@
-624,7
+628,7
@@
sub process
}
# send a prompt if no activity out on this channel
}
# send a prompt if no activity out on this channel
- if ($t >= $dxchan->t + $
main::user_interval
) {
+ if ($t >= $dxchan->t + $
dxchan->{user_interval}
) {
$dxchan->prompt() if $dxchan->{state} =~ /^prompt/o;
$dxchan->t($t);
}
$dxchan->prompt() if $dxchan->{state} =~ /^prompt/o;
$dxchan->t($t);
}
@@
-878,7
+882,6
@@
sub find_cmd_name {
if (isdbg('eval')) {
my @list = split /\n/, $eval;
if (isdbg('eval')) {
my @list = split /\n/, $eval;
- my $line;
for (@list) {
dbg($_ . "\n") if isdbg('eval');
}
for (@list) {
dbg($_ . "\n") if isdbg('eval');
}