thomas: server/kolabd/kolabd kolabquotawarn.in,1.8,1.9

cvs at intevation.de cvs at intevation.de
Thu Feb 2 18:15:45 CET 2006


Author: thomas

Update of /kolabrepository/server/kolabd/kolabd
In directory doto:/tmp/cvs-serv26654

Modified Files:
	kolabquotawarn.in 
Log Message:
Fixes for kolabquotawarn logging added in issue1012:
Don't use user-supplied strings as format string.
Make syslog message shorter by only using basename of kolabquotawarn.
Cyrus doesn't give back an error message, so don't use it.


Index: kolabquotawarn.in
===================================================================
RCS file: /kolabrepository/server/kolabd/kolabd/kolabquotawarn.in,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- kolabquotawarn.in	23 Jan 2006 21:38:23 -0000	1.8
+++ kolabquotawarn.in	2 Feb 2006 17:15:43 -0000	1.9
@@ -39,6 +39,7 @@
 use Kolab;
 use Kolab::Util;
 use Kolab::LDAP;
+use File::Basename;
 use vars qw($opt_d);
 
 Kolab::LDAP::startup;
@@ -65,7 +66,7 @@
   my $prio = shift;
   my $fmt = shift;
 
-  my $text = sprintf( "kolabquotawarn: $fmt", @_ );
+  my $text = sprintf( $fmt, @_ );
 
   #print STDERR "$text\n";
   syslog $prio, $text;
@@ -76,16 +77,15 @@
 # syslog so that people can actually see our messages.
 #
 setlogsock $syslog_socktype;
-openlog $0, $syslog_options, $syslog_facility;
+openlog basename($0), $syslog_options, $syslog_facility;
 
 #
 # Log an error and abort.
 #
 sub fatal_exit {
-    my($first) = shift(@_);
-    printf( STDERR "fatal: $first", @_ );
-    printf( STDERR "\n" );
-    mylog("err", "fatal: $first", @_);
+    my $fmt = shift;
+    printf( STDERR "fatal: $fmt\n", @_ );
+    mylog("err", "fatal: $fmt", @_);
     exit 1;
 }
 
@@ -141,9 +141,9 @@
   $mail->print if $opt_d;
   my $mailer = Mail::Transport::SMTP->new();
   if( $mailer->send( $mail ) ) {
-    mylog("info", "info: Sent quota warning message to $user because quota is at $pct%");
+    mylog("info", "info: Sent quota warning message to %s because quota is at %d%%", $user, $pct);
   } else {
-    mylog("err", "error: Failed sent quota warning message to $user");
+    mylog("err", "error: Failed sent quota warning message to %s", $user);
   }
 }
 
@@ -197,7 +197,7 @@
 					 'User'          => $Kolab::config{'cyrus_admin'},
 					 'Password'      => $Kolab::config{'cyrus_admin_pw'},
 					 'Mechanism'    => 'LOGIN', )
-  || fatal_exit("Unable to authenticate with Cyrus admin interface, Error = `" . $cyrus->error. "'");
+  || fatal_exit("Unable to authenticate with Cyrus admin interface");
 
 ### Mail offending users
 kolablistquotas( $cyrus, 'user/*', '*', $quotawarnpct );





More information about the commits mailing list