Hello all,

In the process of rolling out my own .debs from the cvs version, i searched a little deeper and i noticed that although some of the patches included in the debian package dspam-3.6.8-8 were included in the cvs version, i also noticed that there were a few that weren't in, or were only partially in.

So i went and i converted the dpatch files (used by debian) with quilt, to get my hands on the real diffs, and i tested them one by one against the cvs version of dspam (should i call it 3.8.1 yet?)

I came up with a selection of a few, because:

1 - They seem to implement some small changes in the configuration layout of dspam, which i personally think as improvements, and didn't seem to be a bit too much the "debian way".

2 - They really seem to fix something. At least i know they don't break anything. I've been using them in the debian package for a long time now and i've only been happy about it. But i figure that others with a little more insight of the dspam development should check if they are really improvements/fixes.

I'm attaching that small selection. Those patches that who's code was partially included in cvs were worked on by me, so only the "new" stuff is part of them.


Regards,

Hugo Monteiro

--
ci.fct.unl.pt:~# cat .signature

Hugo Monteiro
Email    : [EMAIL PROTECTED]
Telefone : +351 212948300 Ext.15307

Centro de Informática
Faculdade de Ciências e Tecnologia da
                   Universidade Nova de Lisboa
Quinta da Torre   2829-516 Caparica   Portugal
Telefone: +351 212948596   Fax: +351 212948548
www.ci.fct.unl.pt             [EMAIL PROTECTED]

ci.fct.unl.pt:~# _

## add-config-dir.dpatch by Matthijs Mohlmann <[EMAIL PROTECTED]>
## Converted with quilt from the dspam-3.6.8-8 debian package by
## Hugo Monteiro <[EMAIL PROTECTED]>
diff -urNad dspam-3.6.6~/src/read_config.c dspam-3.6.6/src/read_config.c
--- dspam-3.6.6~/src/read_config.c      2006-05-29 12:53:07.000000000 -0400
+++ dspam-3.6.6/src/read_config.c       2006-05-29 12:53:42.690296936 -0400
@@ -27,6 +27,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
+#include <dirent.h>
 #ifdef HAVE_STRINGS_H
 #include <strings.h>
 #endif
@@ -41,6 +42,9 @@
 #include "pref.h"
 #include "util.h"
 
+long dirread(const char *path, config_t *attrib, long num_root);
+long fileread(const char *path, config_t *attrib, long num_root);
+
 static char *next_normal_token(char **p)
 {
   char *start = *p;
@@ -93,28 +97,73 @@
   return NULL;
 }
 
-config_t read_config(const char *path) {
-  config_t attrib, ptr;
+// Read the files in the directory and pass it to fileread
+// or if it is a file, pass it to fileread.
+long dirread(const char *path, config_t *attrib, long num_root) {
+  DIR *dir_p;
+  char *fulldir;
+  struct dirent *dir_entry_p;
+  int n, m;
+
+  // Strip "\n"
+  char *ptr = strrchr(path, '\n');
+  if (ptr)
+    *ptr = '\0';
+
+  if ((dir_p = opendir(path))) {
+    while((dir_entry_p = readdir(dir_p)))
+    {
+      // We don't need the . and ..
+      if (strcmp(dir_entry_p->d_name, ".") == 0 ||
+          strcmp(dir_entry_p->d_name, "..") == 0)
+        continue;
+
+      // only use files which end in .conf:
+      if (strncmp(dir_entry_p->d_name + strlen(dir_entry_p->d_name) - 5,
+                 ".conf", 5) != 0) {
+       continue;
+      }
+
+      n = strlen(dir_entry_p->d_name);
+      m = strlen(path);
+      fulldir = (char *)malloc(n+m+2);
+      strcpy(fulldir, (char *)path);
+      strcat(fulldir, "/");
+      strcat(fulldir, dir_entry_p->d_name);
+      num_root = fileread((const char *)fulldir, attrib, num_root);
+      free(fulldir);
+    }
+    closedir(dir_p);
+  } else {
+    // Could be a file.
+    return fileread((const char *)path, attrib, num_root);
+  }
+
+  return num_root;
+}
+
+// Read the file and check if there is an Include directive, if so then pass
+// it to dirread.
+long fileread(const char *path, config_t *attrib, long num_root) {
+  config_t ptr;
   FILE *file;
-  long attrib_size = 128, num_root = 0;
+  long attrib_size = 128;
   char buffer[1024];
   char *a, *c, *v, *bufptr = buffer;
 
-  attrib = calloc(1, attrib_size*sizeof(attribute_t));
-  if (attrib == NULL) {
-    LOG(LOG_CRIT, ERR_MEM_ALLOC);
-    return NULL;
-  }
-
   if (path == NULL)
     file = fopen(CONFIG_DEFAULT, "r");
   else
     file = fopen(path, "r");
 
   if (file == NULL) {
-    LOG(LOG_ERR, ERR_IO_FILE_OPEN, CONFIG_DEFAULT, strerror(errno));
-    free(attrib);
-    return NULL;
+    if (path == NULL) {
+      LOG(LOG_ERR, ERR_IO_FILE_OPEN, CONFIG_DEFAULT, strerror(errno));
+    } else {
+      LOG(LOG_ERR, ERR_IO_FILE_OPEN, path, strerror(errno));
+    }
+    free(*attrib);
+    return 0;
   }
 
   while(fgets(buffer, sizeof(buffer), file)!=NULL) {
@@ -130,30 +179,48 @@
       continue; /* Ignore whitespace-only lines */
 
     while ((v = tokenize(NULL, &bufptr)) != NULL) {
-      if (_ds_find_attribute(attrib, a)!=NULL) { 
-        _ds_add_attribute(attrib, a, v);
-      }
-      else {
-        num_root++;
-        if (num_root >= attrib_size) {
-          attrib_size *=2;
-          ptr = realloc(attrib, attrib_size*sizeof(attribute_t)); 
-          if (ptr) 
-            attrib = ptr;
-          else
-            LOG(LOG_CRIT, ERR_MEM_ALLOC);
-        } 
-        _ds_add_attribute(attrib, a, v);
+      // Check for include directive
+      if (strcmp(a, "Include") == 0) {
+        // Give v (value) to dirraed
+        num_root = dirread(v, attrib, num_root);
+      } else {
+        if (_ds_find_attribute((*attrib), a)!=NULL) { 
+          _ds_add_attribute((*attrib), a, v);
+        }
+        else {
+          num_root++;
+          if (num_root >= attrib_size) {
+            attrib_size *=2;
+            ptr = realloc((*attrib), attrib_size*sizeof(attribute_t)); 
+            if (ptr)
+              *attrib = ptr;
+            else
+              LOG(LOG_CRIT, ERR_MEM_ALLOC);
+          } 
+          _ds_add_attribute((*attrib), a, v);
+        }
       }
     }
   }
 
   fclose(file);
 
-  ptr = realloc(attrib, ((num_root+1)*sizeof(attribute_t))+1);
-  if (ptr)
-    return ptr;
-  LOG(LOG_CRIT, ERR_MEM_ALLOC);
+  return num_root;
+}
+
+config_t read_config(const char *path) {
+  config_t attrib;
+  long attrib_size = 128, num_root = 0;
+
+  attrib = calloc(1, attrib_size*sizeof(attribute_t));
+  if (attrib == NULL) {
+    LOG(LOG_CRIT, ERR_MEM_ALLOC);
+    return NULL;
+  }
+
+  if (fileread(path, &attrib, num_root) == 0)
+    return NULL;
+
   return attrib;
 }
 
## background-dspam.dpatch by Matthijs Mohlmann <[EMAIL PROTECTED]>
## Converted with quilt from the dspam-3.6.8-8 debian package by
## Hugo Monteiro <[EMAIL PROTECTED]>
diff -urNad dspam-3.6.2~/src/dspam.c dspam-3.6.2/src/dspam.c
--- dspam-3.6.2~/src/dspam.c    2006-01-02 12:40:52.000000000 +0100
+++ dspam-3.6.2/src/dspam.c     2006-01-02 12:43:04.566063250 +0100
@@ -3830,6 +3830,11 @@
   DRIVER_CTX DTX;
   char *pidfile;
 
+  /* Fork dspam into the background */
+  if (fork()) {
+    exit(EXIT_SUCCESS);
+  }
+
   __daemon_run  = 1;
   __num_threads = 0;
   __hup = 0;
## cleanup-manpages.dpatch by Kurt B. Kaiser <[EMAIL PROTECTED]>
## Converted with quilt from the dspam-3.6.8-8 debian package by
## Hugo Monteiro <[EMAIL PROTECTED]>
diff -urNad dspam~/man/dspam.1 dspam/man/dspam.1
--- dspam~/man/dspam.1  2006-05-14 11:37:30.000000000 -0400
+++ dspam/man/dspam.1   2008-02-24 16:23:41.000000000 -0500
@@ -102,7 +102,7 @@
 delivered, the $u (or %u) parameters of the argument string will be 
interpolated
 for the current user being processed.
  
-.n3 3
+.ne 3
 .TP
 .BI \--mode= [toe|tum|teft|notrain]\c
 Configures the training mode to be used for this process, overriding any
@@ -121,7 +121,7 @@
 : No training.  Do not train the user's data, and do not keep totals.  This 
should only be used in cases where you want to process mail for a particular 
user (based on a group, for example), but don't want the user to accumulate any 
learning data.
 
 .B unlearn
-: Unlearn original training. Use this if you wish to unlearn a previously 
learned message. Be sure to specify --source=error and --class to whatever the 
original classification the message was learned under. If not using 
TrainPristine, this will require the original signature from training.
+: Unlearn original training. Use this if you wish to unlearn a previously 
learned message. Be sure to specify \-\-source=error and \-\-class to whatever 
the original classification the message was learned under. If not using 
TrainPristine, this will require the original signature from training.
 
 .ne 3
 .TP
@@ -150,7 +150,7 @@
 should be used when a misclassification has occured, when the user is
 corpus-feeding a message, or when an inoculation is being presented. This
 flag should not be used for standard processing. This flag must be used in
-conjunction with the --source flag. Omitting this flag causes DSPAM to
+conjunction with the \-\-source flag. Omitting this flag causes DSPAM to
 determine the disposition of the message on its own (the standard operating
 mode).
  
@@ -186,7 +186,7 @@
 .BI \--deliver= [innocent,spam]\c
 Tells
 .B DSPAM
-to deliver the message if its result falls within the criteria specified. For 
example, --deliver=innocent will cause DSPAM to only deliver the message if its 
classification has been determined as innocent. Providing 
--deliver=innocent,spam will cause DSPAM to deliver the message regardless of 
its classification. This flag provides a significant amount of flexibility for 
nonstandard implementations.
+to deliver the message if its result falls within the criteria specified. For 
example, \-\-deliver=innocent will cause DSPAM to only deliver the message if 
its classification has been determined as innocent. Providing 
\-\-deliver=innocent,spam will cause DSPAM to deliver the message regardless of 
its classification. This flag provides a significant amount of flexibility for 
nonstandard implementations.
 
 .ne 3
 .TP
@@ -228,7 +228,7 @@
 .TP
 .BI \--signature =[signature]
 If only the signature is available for training, and not the entire message,
-the --signature flag may be used to feed the signature into DSPAM and forego
+the \-\-signature flag may be used to feed the signature into DSPAM and forego
 the reading of stdin. DSPAM will process the signature with whatever
 commandline classification was specified. NOTE: This should only be used
 with
@@ -241,7 +241,7 @@
 .B DSPAM
 was compiled with
 .B --enable-debug
-then using --debug will turn on debugging messages to /tmp/dspam.debug.
+then using \-\-debug will turn on debugging messages to /tmp/dspam.debug.
 
 .ne 3
 .TP
@@ -250,8 +250,8 @@
 .B DSPAM
 was compiled with
 .B --enable-daemon
-then using --daemon will cause DSPAM to enter daemon mode, where it will listen
-for DSPAM clients to connect and actively service requests.
+then using \-\-daemon will cause DSPAM to enter daemon mode, where it will
+listen for DSPAM clients to connect and actively service requests.
 
 .ne 3
 .TP
@@ -260,7 +260,7 @@
 .B DSPAM
 was compiled with
 .B --enable-daemon
-then using --client will cause DSPAM to act as a client and attempt to connect 
to the DSPAM server specified in the client's configuration within dspam.conf. 
If client behavior is desired, this option
+then using \-\-client will cause DSPAM to act as a client and attempt to 
connect to the DSPAM server specified in the client's configuration within 
dspam.conf. If client behavior is desired, this option
 .B must
 be specified, otherwise the agent simply operate as self-contained and 
processes the message on its own, eliminating any benefit of using the daemon.
 
@@ -269,7 +269,7 @@
 .BI \--rcpt-to\c
 If
 .B DSPAM
-will be configured to deliver via LMTP or SMTP, this flag may be used to 
define the RCPT TOs which will be used for the delivery of each user specified 
with --user. If no recipients are provided, the RCPT TOs will match the 
username.
+will be configured to deliver via LMTP or SMTP, this flag may be used to 
define the RCPT TOs which will be used for the delivery of each user specified 
with \--user. If no recipients are provided, the RCPT TOs will match the 
username.
 NOTE: The recipient list should always be balanced with the user list, or 
empty. Specifying an unbalanced number of recipients to users will result in 
undefined behavior.
 
 .ne 3
diff -urNad dspam~/man/dspam_clean.1 dspam/man/dspam_clean.1
--- dspam~/man/dspam_clean.1    2006-05-14 11:37:30.000000000 -0400
+++ dspam/man/dspam_clean.1     2008-02-24 16:24:19.000000000 -0500
@@ -45,7 +45,7 @@
 14 days will be overridden. Specifying an age of 0 will delete all signatures
 from the user(s) processed.
 
-.n 3
+.ne 3
 .TP
 .BI \-p\fR\c
 Deletes all tokens from the target user(s) database whose probability is
@@ -54,7 +54,7 @@
 to use this flag once with a life of 0 days for users after a significant 
amount
 of corpus training. 
 
-.n 3
+.ne 3
 .TP
 .BI \-u\fR\c
 Deletes all unused tokens from a user's dataset. Four different life values
@@ -73,11 +73,11 @@
 .B ihl
 Tokens with a single innocent hit
 
-Ages may be overridden by specifying a format string, such as -u30,15,10,10
+Ages may be overridden by specifying a format string, such as \-u30,15,10,10
 where each number represents the respective life. Specifying a life of zero
 will delete all unused tokens in the category.
 
-.n 3
+.ne 3
 .TP
 .BI \ user1\ user2\ ...\ userN\fR\c
 Specify the username(s) to perform the selected maintenance operations on. If
diff -urNad dspam~/man/dspam_dump.1 dspam/man/dspam_dump.1
--- dspam~/man/dspam_dump.1     2006-05-14 11:37:30.000000000 -0400
+++ dspam/man/dspam_dump.1      2008-02-24 16:23:41.000000000 -0500
@@ -40,7 +40,7 @@
 .BI \ username \fR\c
 The username of the user to dump
  
-.n3
+.ne 3
 .TP
 .BI \ token \fR\c
 The text string of the token to search for and dump. If no token is specified,
diff -urNad dspam~/man/dspam_merge.1 dspam/man/dspam_merge.1
--- dspam~/man/dspam_merge.1    2006-05-14 11:37:30.000000000 -0400
+++ dspam/man/dspam_merge.1     2008-02-24 16:23:41.000000000 -0500
@@ -32,7 +32,7 @@
 token and per-user totals are added together to produce a single composite
 dataset. After creating a composite user,
 .B dspam_clean
-should be run with the -p option to clean up extraneous data.
+should be run with the \-p option to clean up extraneous data.
 
 .B NOTE
 : Merges may take a considerable amount of time. This could potentially 
increase
@@ -46,7 +46,7 @@
 .BI \ user1\ user2\ ...\ userN \fR\c
 A list of users to merge together.
  
-.n3
+.ne 3
 .TP
 .BI \ -o \ username \fR\c
 The target user which will be created (if necessary). This user will contain
diff -urNad dspam~/man/dspam_stats.1 dspam/man/dspam_stats.1
--- dspam~/man/dspam_stats.1    2008-02-24 16:23:40.000000000 -0500
+++ dspam/man/dspam_stats.1     2008-02-24 16:23:41.000000000 -0500
@@ -62,7 +62,7 @@
 .BI \-t\fR\c
 Displays a total of all statistics displayed
 
-.n3 3
+.ne 3
 .TP
 .BI [username]\c
 Specifies the username to query. If no username is provided, all users will be
diff -urNad dspam~/man/dspam_train.1 dspam/man/dspam_train.1
--- dspam~/man/dspam_train.1    2006-05-14 11:37:30.000000000 -0400
+++ dspam/man/dspam_train.1     2008-02-24 16:24:40.000000000 -0500
@@ -44,18 +44,18 @@
 .ne 3
 .TP
 
-.n3 3
+.ne 3
 .TP
 .BI [username]\c
 Specifies the user to train.
 
-.n3 3
+.ne 3
 .TP
 .BI [spam_dir]\c
 Specifies the pathname to the directory containing the corpus of spam. Each
 message should be separate in its own file.
 
-.n3 3
+.ne 3
 .TP
 .BI [nonspam_dir]\c
 Specifies the pathname to the directory containing the corpus of nonspam. Each 
## fix-manpage-libdspam.dpatch by Matthijs Mohlmann <[EMAIL PROTECTED]>
## Converted with quilt from the dspam-3.6.8-8 debian package by
## Hugo Monteiro <[EMAIL PROTECTED]>
diff -urNad dspam-3.6.8~/man/libdspam.3 dspam-3.6.8/man/libdspam.3
--- dspam-3.6.8~/man/libdspam.3 2006-05-14 17:37:30.000000000 +0200
+++ dspam-3.6.8/man/libdspam.3  2008-01-26 11:33:57.350317993 +0100
@@ -10,7 +10,7 @@
 .\"
 .TH libdspam 1  "Sep 29, 2004" "libdspam" "libdspam"
 
-.SH NAME
+.SH NAME DSPAM \- DSPAM Core Analyis Engine Functions
 libdspam, dspam_init, dspam_create, dspam_addattribute, dspam_attach, 
dspam_process, dspam_getsource, dspam_detach, dspam_clearattributes, 
dspam_destroy 
 .PP
 DSPAM Core Analyis Engine Functions
## fix-tag-class.dpatch by Daniel Kahn Gillmor <[EMAIL PROTECTED]>
## Converted with quilt from the dspam-3.6.8-8 debian package by
## Hugo Monteiro <[EMAIL PROTECTED]>
diff -urNad dspam-3.6.8/src/dspam.c /tmp/dpep.a28IM6/dspam-3.6.8/src/dspam.c
--- dspam-3.6.8/src/dspam.c     2006-06-23 02:37:49.000000000 -0400
+++ /tmp/dpep.a28IM6/dspam-3.6.8/src/dspam.c    2006-06-23 02:43:39.734556401 
-0400
@@ -2698,6 +2698,8 @@
       memcpy(&CTX->totals, &CTC->totals, sizeof(struct _ds_spam_totals));
       free(CTC);
       CTX->totals.spam_misclassified--;
+      strncpy(CTX->class, LANG_CLASS_SPAM, sizeof(CTX->class));
+      /* should we be resetting CTX->probability and CTX->confidence here as 
well? */
       CTX->result = result;
     }
 
@@ -2722,6 +2724,8 @@
       memcpy(&CTX->totals, &CTC->totals, sizeof(struct _ds_spam_totals));
       free(CTC);
       CTX->totals.innocent_misclassified--;
+      strncpy(CTX->class, LANG_CLASS_INNOCENT, sizeof(CTX->class));
+      /* should we be resetting CTX->probability and CTX->confidence here as 
well? */
       CTX->result = result;
     }
   }
## Updates dspam.conf
## Converted with quilt from the dspam-3.6.8-8 debian package by
## Hugo Monteiro <[EMAIL PROTECTED]>
diff -urNad dspam-3.6.8~/src/dspam.conf.in dspam-3.6.8/src/dspam.conf.in
--- dspam-3.6.8~/src/dspam.conf.in      2006-10-07 19:53:52.737369150 +0200
+++ dspam-3.6.8/src/dspam.conf.in       2006-10-07 19:54:11.653493462 +0200
@@ -721,4 +636,7 @@
 #
 ProcessorBias on
 
+# Include a directory with configuration items.
+Include /etc/dspam/dspam.d/
+
 ## EOF
## virus-notifications.dpatch by  <[EMAIL PROTECTED]>
## Converted with quilt from the dspam-3.6.8-8 debian package by
## Hugo Monteiro <[EMAIL PROTECTED]>
diff -urNad dspam-3.6.6~/src/dspam.c dspam-3.6.6/src/dspam.c
--- dspam-3.6.6~/src/dspam.c    2006-05-13 14:17:30.000000000 +0200
+++ dspam-3.6.6/src/dspam.c     2006-05-28 15:24:25.000000000 +0200
@@ -3401,7 +3402,14 @@
             fclose(file);
         }
       }
+      if (CTX->result == DSR_ISSPAM &&
+          strcmp(CTX->class, LANG_CLASS_VIRUS) == 0 &&
+          _ds_match_attribute(agent_config, "TrackSources", "virus"))
+      {
+        LOG (LOG_INFO, "infected message from %s", ip);
+      }
       if (CTX->result != DSR_ISSPAM &&
+          strcmp(CTX->class, LANG_CLASS_VIRUS) != 0 &&
           _ds_match_attribute(agent_config, "TrackSources", "nonspam"))
       {
         LOG (LOG_INFO, "innocent message from %s", ip);

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to