]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
ids-functions.pl: Also log errors to syslog
authorStefan Schantl <stefan.schantl@ipfire.org>
Wed, 14 Feb 2018 13:01:50 +0000 (14:01 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Thu, 26 Jul 2018 09:59:15 +0000 (11:59 +0200)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
config/cfgroot/ids-functions.pl

index 6d3cf72993f09469c17699e616570154adad0caa..d88a5b4ca6e139962a09efafe80c7183d8db377f 100644 (file)
@@ -189,10 +189,36 @@ sub log_error ($) {
        # Remove any newline.
        chomp($error);
 
+       # Call private function to log the error message to syslog.
+       &_log_to_syslog($error);
+
        # Call private function to write/store the error message in the storederrorfile.
        &_store_error_message($error);
 }
 
+#
+## Function to log a given error message to the kernel syslog.
+#
+sub _log_to_syslog ($) {
+       my ($message) = @_;
+
+       # Load perl module to talk to the kernel syslog.
+       use Sys::Syslog qw(:DEFAULT setlogsock);
+
+       # The syslog function works best with an array based input,
+       # so generate one before passing the message details to syslog.
+       my @syslog = ("ERR", "<ERROR> $message");
+
+       # Establish the connection to the syslog service.
+       openlog('oinkmaster', 'cons,pid', 'user');
+
+       # Send the log message.
+       syslog(@syslog);
+
+       # Close the log handle.
+       closelog();
+}
+
 #
 ## Private function to write a given error message to the storederror file.
 #