98_telnet.pm/01_FHEMWEB.pm: revert NotifyFn optimizations from r13334, as it doe not sets motd.

git-svn-id: https://svn.fhem.de/fhem/trunk@13443 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2017-02-19 12:51:22 +00:00
parent 62ee837319
commit 196a8a1eba
2 changed files with 15 additions and 4 deletions

View File

@ -130,6 +130,7 @@ FHEMWEB_Initialize($)
$hash->{DefFn} = "FW_Define"; $hash->{DefFn} = "FW_Define";
$hash->{UndefFn} = "FW_Undef"; $hash->{UndefFn} = "FW_Undef";
$hash->{NotifyFn}= "FW_Notify"; $hash->{NotifyFn}= "FW_Notify";
$hash->{NotifyFn}= ($init_done ? "FW_Notify" : "FW_SecurityCheck");
$hash->{AsyncOutputFn} = "FW_AsyncOutput"; $hash->{AsyncOutputFn} = "FW_AsyncOutput";
$hash->{ActivateInformFn} = "FW_ActivateInform"; $hash->{ActivateInformFn} = "FW_ActivateInform";
no warnings 'qw'; no warnings 'qw';
@ -217,13 +218,15 @@ FHEMWEB_Initialize($)
FW_readIcons($pe); FW_readIcons($pe);
} }
} }
InternalTimer(1, "FW_SecurityCheck", $hash);
} }
##################################### #####################################
sub sub
FW_SecurityCheck($$) FW_SecurityCheck($$)
{ {
my ($ntfy, $dev) = @_;
return if($dev->{NAME} ne "global" ||
!grep(m/^INITIALIZED$/, @{$dev->{CHANGED}}));
my $motd = AttrVal("global", "motd", ""); my $motd = AttrVal("global", "motd", "");
if($motd =~ "^SecurityCheck") { if($motd =~ "^SecurityCheck") {
my @list1 = devspec2array("TYPE=FHEMWEB"); my @list1 = devspec2array("TYPE=FHEMWEB");
@ -244,6 +247,8 @@ FW_SecurityCheck($$)
if(@list3); if(@list3);
$attr{global}{motd} = $motd; $attr{global}{motd} = $motd;
} }
$modules{FHEMWEB}{NotifyFn}= "FW_Notify";
return;
} }
##################################### #####################################
@ -801,7 +806,8 @@ FW_answerCall($)
my $supplied = $FW_webArgs{fwcsrf} ? $FW_webArgs{fwcsrf} : ""; my $supplied = $FW_webArgs{fwcsrf} ? $FW_webArgs{fwcsrf} : "";
my $want = $defs{$FW_wname}{CSRFTOKEN}; my $want = $defs{$FW_wname}{CSRFTOKEN};
if($supplied ne $want) { if($supplied ne $want) {
Log3 $FW_wname, 3, "FHEMWEB $FW_wname CSRF error: $supplied ne $want"; Log3 $FW_wname, 3, "FHEMWEB $FW_wname CSRF error: $supplied ne $want. ".
"For detals see the csrfToken FHEMWEB attribute";
return 0; return 0;
} }
} }

View File

@ -20,6 +20,7 @@ telnet_Initialize($)
$hash->{AsyncOutputFn} = "telnet_Output"; $hash->{AsyncOutputFn} = "telnet_Output";
$hash->{UndefFn} = "telnet_Undef"; $hash->{UndefFn} = "telnet_Undef";
$hash->{AttrFn} = "telnet_Attr"; $hash->{AttrFn} = "telnet_Attr";
$hash->{NotifyFn}= "telnet_SecurityCheck";
$hash->{AttrList} = "globalpassword password prompt allowedCommands ". $hash->{AttrList} = "globalpassword password prompt allowedCommands ".
"allowfrom SSL connectTimeout connectInterval ". "allowfrom SSL connectTimeout connectInterval ".
"encoding:utf8,latin1 sslVersion"; "encoding:utf8,latin1 sslVersion";
@ -33,7 +34,6 @@ telnet_Initialize($)
$cmds{inform} = { Fn=>"CommandTelnetInform", $cmds{inform} = { Fn=>"CommandTelnetInform",
ClientFilter => "telnet", ClientFilter => "telnet",
Hlp=>"{on|off|log|raw|timer|status},echo all events to this client" }; Hlp=>"{on|off|log|raw|timer|status},echo all events to this client" };
InternalTimer(1, "telnet_SecurityCheck", $hash);
} }
sub sub
@ -58,8 +58,11 @@ CommandTelnetEncoding($$)
##################################### #####################################
sub sub
telnet_SecurityCheck() telnet_SecurityCheck($$)
{ {
my ($ntfy, $dev) = @_;
return if($dev->{NAME} ne "global" ||
!grep(m/^INITIALIZED$/, @{$dev->{CHANGED}}));
my $motd = AttrVal("global", "motd", ""); my $motd = AttrVal("global", "motd", "");
if($motd =~ "^SecurityCheck") { if($motd =~ "^SecurityCheck") {
my @list1 = devspec2array("TYPE=telnet"); my @list1 = devspec2array("TYPE=telnet");
@ -82,6 +85,8 @@ telnet_SecurityCheck()
if(@list3); if(@list3);
$attr{global}{motd} = $motd; $attr{global}{motd} = $motd;
} }
delete $modules{telnet}{NotifyFn};
return;
} }
########################## ##########################