From 0e40e1e772b2f29e71df807f9cb07098b0d23034 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Wed, 14 Feb 2018 14:00:57 +0100 Subject: [PATCH] ids-functions.pl: Use pure perl to log oinkmaster result to syslog Signed-off-by: Stefan Schantl --- config/cfgroot/ids-functions.pl | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/config/cfgroot/ids-functions.pl b/config/cfgroot/ids-functions.pl index c8b0c568d0..6d3cf72993 100644 --- a/config/cfgroot/ids-functions.pl +++ b/config/cfgroot/ids-functions.pl @@ -154,8 +154,30 @@ sub downloadruleset { ## A tiny wrapper function to call the oinkmaster script. # sub oinkmaster () { + # Load perl module to talk to the kernel syslog. + use Sys::Syslog qw(:DEFAULT setlogsock); + + # Establish the connection to the syslog service. + openlog('oinkmaster', 'cons,pid', 'user'); + # Call oinkmaster to generate ruleset. - system("/usr/local/bin/oinkmaster.pl -v -s -u file://$rulestarball -C /var/ipfire/snort/oinkmaster.conf -o /etc/snort/rules 2>&1 |logger -t oinkmaster"); + open(OINKMASTER, "/usr/local/bin/oinkmaster.pl -v -s -u file://$rulestarball -C /var/ipfire/snort/oinkmaster.conf -o /etc/snort/rules|"); + + # Log output of oinkmaster to syslog. + while() { + # The syslog function works best with an array based input, + # so generate one before passing the message details to syslog. + my @syslog = ("INFO", "$_"); + + # Send the log message. + syslog(@syslog); + } + + # Close the pipe to oinkmaster process. + close(OINKMASTER); + + # Close the log handle. + closelog(); } # -- 2.39.2