diff --git a/Changes b/Changes index 7f265b3..2f2dbb7 100644 --- a/Changes +++ b/Changes @@ -20,6 +20,9 @@ - Fixed the MIME type of graphs in 'emailreports.pm' and in 'traffacct.pm' to honor the 'image_format' option. [#174] - Fixed in 'emailreports.pm' to name each attached graph correctly. +- Fixed the message 'Odd number of elements in hash assignment' in + HTTPServer.pm line 58, generated by a malformed line in the 'htpasswd' file. + Now it warns about such malformed line in the HTTP built-in log. 3.9.0 - 14-Oct-2016 diff --git a/lib/HTTPServer.pm b/lib/HTTPServer.pm index 42d830e..d9a00d5 100644 --- a/lib/HTTPServer.pm +++ b/lib/HTTPServer.pm @@ -55,7 +55,21 @@ sub check_passwd { if(open(IN, $main::config{httpd_builtin}->{auth}->{htpasswd})) { while() { - my %pair = split(':', $_); + my $line = trim($_); + + # append character ':' if not exist + if(index($line, ":") < 0) { + logger("Malformed line in " . $main::config{httpd_builtin}->{auth}->{htpasswd}, "ERROR"); + $line .= ":" if index($line, ":") < 0; + } + + # discard that line if password is missing + if(length($line) == index($line, ":") + 1) { + logger("Malformed line in " . $main::config{httpd_builtin}->{auth}->{htpasswd}, "ERROR"); + next; + } + + my %pair = split(':', $line); if($pair{$user || ""}) { chomp($pair{$user}); if(crypt($pass, $pair{$user}) ne $pair{$user}) {