diff --git a/CHANGED b/CHANGED index e0a425ff1..be4795706 100644 --- a/CHANGED +++ b/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - changed: allowed.pm/fhem.pl: SecurityCheck cleanup, Forum #81509 - new: 88_xs1Bridge: New modul to read xs1 EZcontrol - change: 93_DbRep: V7.0.0, changelog: - faster exec if no time attribut/aggregation is set diff --git a/FHEM/01_FHEMWEB.pm b/FHEM/01_FHEMWEB.pm index 9a5520f06..1dd0e0c6c 100644 --- a/FHEM/01_FHEMWEB.pm +++ b/FHEM/01_FHEMWEB.pm @@ -132,7 +132,7 @@ FHEMWEB_Initialize($) $hash->{AttrFn} = "FW_Attr"; $hash->{DefFn} = "FW_Define"; $hash->{UndefFn} = "FW_Undef"; - $hash->{NotifyFn}= ($init_done ? "FW_Notify" : "FW_SecurityCheck"); + $hash->{NotifyFn}= "FW_Notify"; $hash->{AsyncOutputFn} = "FW_AsyncOutput"; $hash->{ActivateInformFn} = "FW_ActivateInform"; no warnings 'qw'; @@ -226,37 +226,6 @@ FHEMWEB_Initialize($) } } -##################################### -sub -FW_SecurityCheck($$) -{ - my ($ntfy, $dev) = @_; - return if($dev->{NAME} ne "global" || - !grep(m/^INITIALIZED$/, @{$dev->{CHANGED}})); - my $motd = AttrVal("global", "motd", ""); - if($motd =~ "^SecurityCheck") { - my @list1 = devspec2array("TYPE=FHEMWEB"); - my @list2 = devspec2array("TYPE=allowed"); - my @list3; - for my $l (@list1) { # This is a hack, as hardcoded to basicAuth - next if(!$defs{$l}); - my $fnd = 0; - for my $a (@list2) { - next if(!$defs{$a}); - my $vf = AttrVal($a, "validFor",""); - $fnd = 1 if($vf && ($vf =~ m/\b$l\b/) && AttrVal($a, "basicAuth","")); - } - push @list3, $l if(!$fnd); - } - $motd .= (join(",", sort @list3). - " has no associated allowed device with basicAuth.\n") - if(@list3); - $attr{global}{motd} = $motd; - } - $modules{FHEMWEB}{NotifyFn}= "FW_Notify"; - return; -} - ##################################### sub FW_Define($$) @@ -1070,8 +1039,7 @@ FW_answerCall($) } else { my $motd = AttrVal("global","motd","none"); if($motd ne "none") { - $motd =~ s/\n/
/g; - FW_addContent(">$motd
$motd
{".httpAuthHeader"}; return 0 if(!$basicAuth); + return 2 if(!$param); my $FW_httpheader = $param; my $secret = $FW_httpheader->{Authorization}; @@ -173,6 +175,7 @@ allowed_Authenticate($$$$) my $pw = AttrVal($aName, "password", undef); if(!$pw) { $pw = AttrVal($aName, "globalpassword", undef); + return 2 if($pw && !defined($param)); $pw = undef if($pw && $cl->{NAME} =~ m/_127.0.0.1_/); } return 0 if(!$pw); @@ -244,8 +247,10 @@ allowed_Attr(@) } else { delete($hash->{$attrName}); } - readingsSingleUpdate($hash, "state", "validFor:".join(",",@param), 1) - if($attrName eq "validFor"); + if($attrName eq "validFor") { + readingsSingleUpdate($hash, "state", "validFor:".join(",",@param), 1); + InternalTimer(1, "SecurityCheck", 0) if($init_done); + } } elsif(($attrName eq "basicAuth" || $attrName eq "password" || $attrName eq "globalpassword") && @@ -253,6 +258,7 @@ allowed_Attr(@) foreach my $d (devspec2array("TYPE=(FHEMWEB|telnet)")) { delete $defs{$d}{Authenticated} if($defs{$d}); } + InternalTimer(1, "SecurityCheck", 0) if($init_done); } return undef; @@ -266,11 +272,16 @@ allowed_fhemwebFn($$$$) my $hash = $defs{$d}; my $vf = $defs{$d}{validFor} ? $defs{$d}{validFor} : ""; - my @arr = map { "" } + my (@F_arr, @t_arr); + my @arr = map { + push(@F_arr, $_) if($defs{$_}{TYPE} eq "FHEMWEB"); + push(@t_arr, $_) if($defs{$_}{TYPE} eq "telnet"); + "" + } grep { !$defs{$_}{SNAME} } devspec2array("TYPE=(FHEMWEB|telnet)"); - return " $d validFor