[6/7] IPS: Do not try to show rules when stat on rules tarball fails

Message ID 20211119174458.789486-6-michael.tremer@ipfire.org
State Accepted
Commit 9268cddfd284f82df51fd76c48b1810f5980620e
Headers show
Series [1/7] suricata: Include all default rules | expand

Commit Message

Michael Tremer Nov. 19, 2021, 5:44 p.m. UTC
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 html/cgi-bin/ids.cgi | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Patch

diff --git a/html/cgi-bin/ids.cgi b/html/cgi-bin/ids.cgi
index 85c5ddd86..4e8b28fd8 100644
--- a/html/cgi-bin/ids.cgi
+++ b/html/cgi-bin/ids.cgi
@@ -1091,13 +1091,14 @@  if (%idsrules) {
 	# Call stat on the rulestarball.
 	my $stat = stat("$IDS::rulestarball");
 
-	# Get timestamp the file creation.
-	my $mtime = $stat->mtime;
+	if (defined $stat) {
+		# Get timestamp the file creation.
+		my $mtime = $stat->mtime;
 
-	# Convert into human read-able format.
-	my $rulesdate = strftime('%Y-%m-%d %H:%M:%S', localtime($mtime));
+		# Convert into human read-able format.
+		my $rulesdate = strftime('%Y-%m-%d %H:%M:%S', localtime($mtime));
 
-	&Header::openbox('100%', 'LEFT', "$Lang::tr{'intrusion detection system rules'} ($rulesdate)" );
+		&Header::openbox('100%', 'LEFT', "$Lang::tr{'intrusion detection system rules'} ($rulesdate)" );
 
 		print"<form method='POST' action='$ENV{'SCRIPT_NAME'}'>\n";
 
@@ -1189,7 +1190,7 @@  if (%idsrules) {
 		# Close display table
 		print "</table>";
 
-print <<END
+		print <<END
 <table width='100%'>
 <tr>
 	<td width='100%' align='right'><input type='submit' name='RULESET' value='$Lang::tr{'ids apply'}'></td>
@@ -1198,7 +1199,8 @@  print <<END
 </form>
 END
 ;
-	&Header::closebox();
+		&Header::closebox();
+	}
 }
 
 &Header::closebigbox();