Update of /cvsroot/mahogany/M/lib/dspam/tools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29950/tools

Modified Files:
        dspam_clean.c dspam_stats.c 
Removed Files:
        Makefile.in 
Log Message:
after dspam 3.2 RC1 merge

Index: dspam_clean.c
===================================================================
RCS file: /cvsroot/mahogany/M/lib/dspam/tools/dspam_clean.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -u -2 -r1.2 -r1.3
--- dspam_clean.c       12 Jul 2004 14:26:39 -0000      1.2
+++ dspam_clean.c       2 Oct 2004 13:32:46 -0000       1.3
@@ -46,4 +46,5 @@
 #include "libdspam.h"
 #include "language.h"
+#include "read_config.h"
 
 DSPAM_CTX *open_ctx = NULL, *open_mtx = NULL;
@@ -54,5 +55,5 @@
 void dieout (int signal);
 
-#define CLEANSYNTAX "dspam_clean [-s[age] -p[age] -u[any,quota,nospam,onehit] -h] 
[user1 user2 ... userN]\n"
+#define CLEANSYNTAX "dspam_clean [-s[age] -p[age] -u[any,hapax,nospam,onehit] -h] 
[user1 user2 ... userN]\n"
 
 int
@@ -64,24 +65,74 @@
   int do_probs  = 0;
   int do_unused = 0;
-  int age_sigs   = SIGNATURE_LIFE;
+  int age_sigs   = 14;
   int age_probs  = 30;
-  int age_unused[4] = { 90, 45, 30, 15 };
+  int age_unused[4] = { 90, 30, 15, 15 };
   int i, help = 0;
   struct nt *users;
   struct nt_node *node = NULL;
-
+#ifndef _WIN32
 #ifdef TRUSTED_USER_SECURITY
   struct passwd *p = getpwuid (getuid ());
                                                                                 
-  if (!_ds_is_trusted(p)) {
-    fprintf(stderr, "Only trusted users may run this utility.\n");
+#endif
+#endif
+
+ /* Read dspam.conf */
+                                                                                
+  agent_config = read_config(NULL);
+  if (!agent_config) {
+    report_error("Unable to read configuration");
+    exit(EXIT_FAILURE);
+  }
+                                                                                
+  if (!_ds_read_attribute(agent_config, "Home")) {
+    report_error("DSPAM Home must be defined in dspam.conf");
     exit(EXIT_FAILURE);
   }
 #endif
                                                                                 
+#ifndef _WIN32
+#ifdef TRUSTED_USER_SECURITY
+  if (!_ds_match_attribute(agent_config, "Trust", p->pw_name)) {
+    fprintf(stderr, "Only trusted users may use this tool\n");
+    exit(EXIT_FAILURE);
+  }
+#endif
+#endif
+                                                                                
 #ifdef DEBUG
   fprintf (stderr, "dspam_clean starting\n");
 #endif
 
+  if (_ds_read_attribute(agent_config, "PurgeSignatures") &&
+      !_ds_match_attribute(agent_config, "PurgeSignatures", "off"))  
+  {
+    do_sigs = 1;
+    age_sigs = atoi(_ds_read_attribute(agent_config, "PurgeSignatures"));
+  }
+  
+  if (_ds_read_attribute(agent_config, "PurgeNeutral") &&
+      !_ds_match_attribute(agent_config, "PurgeNeutral", "off"))
+  {
+    do_probs = 1;
+    age_probs = atoi(_ds_read_attribute(agent_config, "PurgeNeutral"));
+  }
+
+  if (_ds_read_attribute(agent_config, "PurgeUnused") &&
+      !_ds_match_attribute(agent_config, "PurgeUnused", "off"))
+  {
+    int i;
+
+    do_unused = 1;
+    age_unused[0] = atoi(_ds_read_attribute(agent_config, "PurgeUnused"));
+    age_unused[1] = atoi(_ds_read_attribute(agent_config, "PurgeHapaxes"));
+    age_unused[2] = atoi(_ds_read_attribute(agent_config, "PurgeHits1S"));
+    age_unused[3] = atoi(_ds_read_attribute(agent_config, "PurgeHits1I"));
+
+    for(i=0;i<4;i++) 
+      if (age_unused[i]==0)
+        do_unused = 0;
+  }
+
   users = nt_create(NT_CHAR);
   if (users == NULL) {
@@ -138,5 +189,5 @@
 
   if (users->items == 0) {
-    CTX = dspam_init (NULL, NULL, DSM_TOOLS, 0);
+    CTX = dspam_create (NULL, NULL, _ds_read_attribute(agent_config, "Home"), 
DSM_TOOLS, 0);
     open_ctx = CTX;
     if (CTX == NULL)
@@ -147,4 +198,10 @@
     }
 
+    set_libdspam_attributes(CTX);
+    if (dspam_attach(CTX, NULL)) {
+      LOG (LOG_WARNING, "unable to attach dspam context");
+      exit(EXIT_FAILURE);
+    }
+
     user = _ds_get_nextuser (CTX);
   } else {
@@ -161,5 +218,5 @@
     printf ("PROCESSING USER: %s\n", user);
 #endif
-    CTX2 = dspam_init (user, NULL, DSM_TOOLS, 0);
+    CTX2 = dspam_create (user, NULL,  _ds_read_attribute(agent_config, "Home"), 
DSM_TOOLS, 0);
     open_mtx = CTX2;
 
@@ -171,4 +228,11 @@
     }
 
+    set_libdspam_attributes(CTX2);
+    if (dspam_attach(CTX2, NULL)) {
+      LOG (LOG_WARNING, "unable to attach dspam context");
+      dspam_destroy(open_ctx);
+      exit(EXIT_FAILURE);
+    }
+
     if (do_sigs)
       process_sigs(CTX2, age_sigs);

Index: dspam_stats.c
===================================================================
RCS file: /cvsroot/mahogany/M/lib/dspam/tools/dspam_stats.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -b -u -2 -r1.3 -r1.4
--- dspam_stats.c       10 Jul 2004 16:26:02 -0000      1.3
+++ dspam_stats.c       2 Oct 2004 13:32:46 -0000       1.4
@@ -39,4 +39,5 @@
 
 #include "libdspam.h"
+#include "../read_config.h"
 
 #define TSYNTAX        "syntax: dspam_stats [username]"
@@ -59,11 +60,32 @@
 
 #ifndef _WIN32
+#ifdef TRUSTED_USER_SECURITY
   struct passwd *p = getpwuid (getuid ());
                                                                                 
-  if (!_ds_is_trusted(p)) {
-    fprintf(stderr, "Only trusted users may run this utility.\n");
+#endif
+#endif
+
+ /* Read dspam.conf */
+                                                                                
+  agent_config = read_config(NULL);
+  if (!agent_config) {
+    report_error("Unable to read configuration");
+    exit(EXIT_FAILURE);
+  }
+                                                                                
+  if (!_ds_read_attribute(agent_config, "Home")) {
+    report_error("DSPAM Home must be defined in dspam.conf");
+    exit(EXIT_FAILURE);
+  }
+                                                                                
+#ifndef _WIN32
+#ifdef TRUSTED_USER_SECURITY
+  if (!_ds_match_attribute(agent_config, "Trust", p->pw_name)) {
+    fprintf(stderr, "Only trusted users may use this tool\n");
     exit(EXIT_FAILURE);
   }
 #endif
+#endif
+
 
   open_ctx = open_mtx = NULL;
@@ -136,5 +158,5 @@
   char *user;
 
-  CTX = dspam_init (NULL, NULL, DSM_TOOLS, 0);
+  CTX = dspam_create (NULL, NULL, _ds_read_attribute(agent_config, "Home"), 
DSM_TOOLS, 0);
   open_ctx = CTX;
   if (CTX == NULL)
@@ -144,4 +166,10 @@
   }
 
+  set_libdspam_attributes(CTX);
+  if (dspam_attach(CTX, NULL)) {
+    LOG (LOG_WARNING, "unable to attach dspam context");
+    exit(EXIT_FAILURE);
+  }
+
   user = _ds_get_nextuser (CTX);
   while (user != NULL)
@@ -162,5 +190,5 @@
   long total_spam, total_innocent, spam_misclassified, innocent_misclassified, 
spam_corpusfed, innocent_corpusfed;
 
-  MTX = dspam_init (username, NULL, DSM_CLASSIFY, 0);
+  MTX = dspam_create (username, NULL, _ds_read_attribute(agent_config, "Home"), 
DSM_CLASSIFY, 0);
   open_mtx = MTX;
   if (MTX == NULL)
@@ -170,4 +198,11 @@
   }
 
+  set_libdspam_attributes(MTX);
+  if (dspam_attach(MTX, NULL)) {
+    LOG (LOG_WARNING, "unable to attach dspam context");
+    return EUNKNOWN;
+  }
+
+
   /* Convenience variables. Compiling with optimization will cause this to have 0 
slowdown,
    * as it is essentially dead code */

--- Makefile.in DELETED ---



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to