[RADIATOR] [patch] AuthLogSYSLOG.pm new option LogOpt

Bjoern A. Zeeb bz-lists at cksoft.de
Mon Mar 29 10:06:04 CDT 2010


Hi Hugh, Mike,

please find attached a diff that lets one control the logopts passed to
openlog(3) in AuthLogSYSLOG.pm.

In case you do not want to validate the options, you can drop
the entire 2nd hunk ("sub new") from the diff. It's a trade between
Syslog internals and error catching. It's picky on whitespace.
Openlog in native mode might not do the right thing in case of
misconfiguration to my understanding and I had prefered to catch that
as early as possible.

We found we could save ~250MB of logs a day by just dropping
the "[pid]" part.

Best Regards,
Bjoern

PS: the patch was forward ported from 4.4 and not tested on latest;)

--- Radius/AuthLogSYSLOG.pm.orig	2009-11-20 22:06:12.000000000 +0000
+++ Radius/AuthLogSYSLOG.pm	2010-03-29 14:43:58.000000000 +0000
@@ -38,2 +38,5 @@ use strict;

+ 'LogOpt'      => 
+ ['string', 'This optional comma separated parameter specifies an alternative set of options for openlog(3). Defaults to \'pid\'.', 1],
+
   'LogHost'       => 
@@ -47,2 +50,17 @@ $Radius::AuthLogSYSLOG::VERSION = '$Revi
  #####################################################################
+sub new
+{
+  my ($class, $file, @args) = @_;
+
+  my $self = $class->SUPER::new($file, @args);
+
+  # Validate LogOpt.
+  map { 
+    die "Invalid LogOpt '$_' to openlog(3)."
+      unless ($_ =~ /^(cons|ndelay|nofatal|nowait|perror|pid)$/)
+  } split /,/, $self->{LogOpt};
+
+  return $self;
+}
+
  # Do per-instance default initialization
@@ -64,2 +82,3 @@ sub initialize
      $self->{LogIdent} = $0;
+    $self->{LogOpt} = 'pid';
  }
@@ -109,2 +128,3 @@ sub authlog
      my $ident = &Radius::Util::format_special($self->{LogIdent}, $p);
+    my $logopt = &Radius::Util::format_special($self->{LogOpt}, $p);
      eval {
@@ -114,3 +134,3 @@ sub authlog
  		if defined $self->{LogSock};
-	    openlog($ident, 'pid', $self->{Facility});
+	    openlog($ident, $logopt, $self->{Facility});
  	    syslog("$self->{Facility}|$self->{Priority}", $str);
-- 
Dipl. Ing. (BA) Bjoern A. Zeeb          Research & Development
CK Software GmbH                        http://www.cksoft.de/
Schwarzwaldstr. 31                      Phone: +49 7452 889 135
D-71131 Jettingen                       Fax: +49 7452 889 136
HRB245288, Amtsgericht Stuttgart        Geschaeftsfuehrer: Christian Kratzer


More information about the radiator mailing list