thomas: server/kolabd/kolabd kolabquotawarn,1.3.2.8,1.3.2.9

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


Author: thomas

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

Modified Files:
      Tag: kolab_2_0_branch
	kolabquotawarn 
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
===================================================================
RCS file: /kolabrepository/server/kolabd/kolabd/Attic/kolabquotawarn,v
retrieving revision 1.3.2.8
retrieving revision 1.3.2.9
diff -u -d -r1.3.2.8 -r1.3.2.9
--- kolabquotawarn	2 Feb 2006 16:36:35 -0000	1.3.2.8
+++ kolabquotawarn	2 Feb 2006 17:15:50 -0000	1.3.2.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;
 }
 
@@ -142,9 +142,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);
   }
 }
 
@@ -198,7 +198,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