changeset 89:946fc1bcfb2c stable-5-3

don't load null config pointer, keep the old one
author carl
date Sun, 07 Aug 2005 11:26:37 -0700
parents 7245c45cef7a
children 962a1f8f1d9f
files ChangeLog dnsbl.spec.in package.bash src/dnsbl.cpp test.bash xml/dnsbl.in xml/sample.conf
diffstat 7 files changed, 1544 insertions(+), 1518 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Aug 01 19:32:03 2005 -0700
+++ b/ChangeLog	Sun Aug 07 11:26:37 2005 -0700
@@ -1,5 +1,11 @@
     $Id$
 
+5.3 2005-08-07
+    Properly quit if the config file has syntax errors on startup.  Send
+    mail to root if the config file needs to be reloaded since it was
+    modified, but contains syntax errors.  In this case, we continue to
+    use the old configuration.
+
 5.2 2005-08-02
     Patch from Stephen Johnson <stephen.johnson@arkansas.gov> fixing the
     lack of a default return value in CONTEXT::acceptable_content().
--- a/dnsbl.spec.in	Mon Aug 01 19:32:03 2005 -0700
+++ b/dnsbl.spec.in	Sun Aug 07 11:26:37 2005 -0700
@@ -1,6 +1,6 @@
 Summary: DNSBL Sendmail Milter
 Name: dnsbl
-Version: 5.2
+Version: 5.3
 Release: 2
 Copyright: GPL
 Group: System Environment/Daemons
--- a/package.bash	Mon Aug 01 19:32:03 2005 -0700
+++ b/package.bash	Sun Aug 07 11:26:37 2005 -0700
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-VER=dnsbl-5.2
+VER=dnsbl-5.3
 mkdir $VER
     target1=/home/httpd/html/510sg/util/dnsbl.tar.gz
     target2=/home/httpd/html/510sg/dnsbl.conf
--- a/src/dnsbl.cpp	Mon Aug 01 19:32:03 2005 -0700
+++ b/src/dnsbl.cpp	Sun Aug 07 11:26:37 2005 -0700
@@ -1007,6 +1007,7 @@
         }
         if (reload) {
             CONFIG *newc = new_conf();
+			if (newc) {
             // replace the global config pointer
             pthread_mutex_lock(&config_mutex);
                 CONFIG *old = config;
@@ -1014,6 +1015,14 @@
             pthread_mutex_unlock(&config_mutex);
             if (old) old_configs.insert(old);
         }
+			else {
+				// failed to load new config
+				my_syslog("failed to load new configuration");
+				system("echo 'failed to load new dnsbl configuration from /etc/dnsbl' | mail -s 'error in /etc/dnsbl configuration' root");
+				// update the load time on the current config to prevent complaining every 3 minutes
+				dc.load_time = time(NULL);
+			}
+		}
         // now look for old configs with zero ref counts
         for (configp_set::iterator i=old_configs.begin(); i!=old_configs.end(); ) {
             CONFIG *old = *i;
@@ -1266,6 +1275,13 @@
         }
     }
 
+	// load the initial config
+	config = new_conf();
+	if (!config) {
+		my_syslog("failed to load initial configuration, quitting");
+		exit(1);
+	}
+
     // fork off the resolver listener process
     pid_t child = fork();
     if (child < 0) {
@@ -1336,9 +1352,6 @@
         sleep(2);   // allow child to get started
     }
 
-    // load the initial config
-    config = new_conf();
-
     // only create threads after the fork() in daemon
     pthread_t tid;
     if (pthread_create(&tid, 0, config_loader, 0))
--- a/test.bash	Mon Aug 01 19:32:03 2005 -0700
+++ b/test.bash	Sun Aug 07 11:26:37 2005 -0700
@@ -47,7 +47,7 @@
 chmod 700 /var/run/dnsbl
 chown dnsbl:dnsbl /var/run/dnsbl
 mv -f $pid $pid.save
-./dnsbl -d -r /var/run/dnsbl/dnsbl.resolver.sock2 -p local:/var/run/dnsbl/dnsbl.sock2
+./dnsbl -d 10 -r /var/run/dnsbl/dnsbl.resolver.sock2 -p local:/var/run/dnsbl/dnsbl.sock2
 sleep 5
 P2=`cat $pid`
 mv -f $pid.save $pid
--- a/xml/dnsbl.in	Mon Aug 01 19:32:03 2005 -0700
+++ b/xml/dnsbl.in	Sun Aug 07 11:26:37 2005 -0700
@@ -2,7 +2,7 @@
 
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
-<title>DNSBL Sendmail milter - Version 5.2</title>
+<title>DNSBL Sendmail milter - Version 5.3</title>
 </head>
 
 <center>Introduction</center>
@@ -30,6 +30,12 @@
 <p>The DNSBL milter reads a text configuration file (dnsbl.conf) on
 startup, and whenever the config file (or any of the referenced include
 files) is changed.  The entire configuration file is case insensitive.
+If the configuration cannot be loaded due to a syntax error, the milter
+will log the error and quit.  If the configuration cannot be reloaded
+after being modified, the milter will log the error and send an email to
+root from dnsbl@$hostname.  You probably want to added dnsbl@$hostname
+to your /etc/mail/virtusertable since otherwise sendmail will reject
+that message.
 
 <hr> <center>DCC Issues</center>
 <p>If you are also using the <a
--- a/xml/sample.conf	Mon Aug 01 19:32:03 2005 -0700
+++ b/xml/sample.conf	Sun Aug 07 11:26:37 2005 -0700
@@ -50,8 +50,9 @@
         ignore    { include "hosts-ignore.conf"; };
         tld       { include "tld.conf"; };
         html_tags { include "html-tags.conf"; };
+        html_limit on 20 "Mail containing excessive bad html tags rejected";
         html_limit off;
-        host_limit on 20 "Mail containing excessive bad html tags rejected";
+        host_limit on 20 "Mail containing excessive host names rejected";
         host_limit soft 20;
     };