]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - config/cfgroot/ids-functions.pl
ids-functions.pl: Use pure perl to log oinkmaster result to syslog
[ipfire-2.x.git] / config / cfgroot / ids-functions.pl
index c8b0c568d0b1a43e763315507b0624f67da19ca0..6d3cf72993f09469c17699e616570154adad0caa 100644 (file)
@@ -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(<OINKMASTER>) {
+               # 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();
 }
 
 #