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

Modified Files:
        dspam_clean.c dspam_dump.c dspam_stats.c 
Removed Files:
        .cvsignore 
Log Message:
after 3.2.0 merge

Index: dspam_clean.c
===================================================================
RCS file: /cvsroot/mahogany/M/lib/dspam/tools/dspam_clean.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -b -u -2 -r1.3 -r1.4
--- dspam_clean.c       2 Oct 2004 13:32:46 -0000       1.3
+++ dspam_clean.c       23 Oct 2004 16:13:02 -0000      1.4
@@ -1,5 +1,7 @@
+/* $Id$ */
+
 /*
  DSPAM
- COPYRIGHT (C) 2003 NETWORK DWEEBS CORPORATION
+ COPYRIGHT (C) 2002-2004 NETWORK DWEEBS CORPORATION
 
 This program is free software; you can redistribute it and/or
@@ -47,4 +49,6 @@
 #include "language.h"
 #include "read_config.h"
+#include "pref.h"
+#include "error.h"
 
 DSPAM_CTX *open_ctx = NULL, *open_mtx = NULL;
@@ -69,5 +73,5 @@
   int age_unused[4] = { 90, 30, 15, 15 };
   int i, help = 0;
-  struct nt *users;
+  struct nt *users = NULL;
   struct nt_node *node = NULL;
 #ifndef _WIN32
@@ -82,11 +86,11 @@
   agent_config = read_config(NULL);
   if (!agent_config) {
-    report_error("Unable to read configuration");
+    report_error(ERROR_READ_CONFIG);
     exit(EXIT_FAILURE);
   }
                                                                                 
   if (!_ds_read_attribute(agent_config, "Home")) {
-    report_error("DSPAM Home must be defined in dspam.conf");
-    exit(EXIT_FAILURE);
+    report_error(ERROR_DSPAM_HOME);
+    goto bail;
   }
 #endif
@@ -94,11 +98,25 @@
 #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);
+  if (!_ds_match_attribute(agent_config, "Trust", p->pw_name) && p->pw_uid) {
+    fprintf(stderr, ERROR_TRUSTED_MODE "\n");
+    goto bail;
   }
 #endif
 #endif
                                                                                 
+  for(i=0;i<argc;i++) {
+                                                                                
+    if (!strncmp (argv[i], "--profile=", 10))
+    {
+      if (!_ds_match_attribute(agent_config, "Profile", argv[i]+10)) {
+        report_error_printf(ERROR_NO_SUCH_PROFILE, argv[i]+10);
+        goto bail;
+      } else {
+        _ds_overwrite_attribute(agent_config, "DefaultProfile", argv[i]+10);
+      }
+      break;
+    }
+  }
+
 #ifdef DEBUG
   fprintf (stderr, "dspam_clean starting\n");
@@ -138,5 +156,5 @@
   if (users == NULL) {
     fprintf(stderr, "%s", ERROR_MEM_ALLOC);
-    exit(EXIT_FAILURE);
+    goto bail;
   }
 
@@ -173,4 +191,6 @@
   if (!do_probs && !do_sigs && !do_unused) {
     fprintf(stderr, "%s", CLEANSYNTAX);
+    _ds_destroy_attributes(agent_config);
+    nt_destroy(users);
     if (help)
       exit(EXIT_SUCCESS);
@@ -195,5 +215,5 @@
       fprintf (stderr, "Could not initialize context: %s\n", strerror (errno));
       dspam_shutdown_driver ();
-      exit (EXIT_FAILURE);
+      goto bail;
     }
 
@@ -201,5 +221,5 @@
     if (dspam_attach(CTX, NULL)) {
       LOG (LOG_WARNING, "unable to attach dspam context");
-      exit(EXIT_FAILURE);
+      goto bail;
     }
 
@@ -210,5 +230,5 @@
       user = node->ptr;
     else
-      exit(EXIT_FAILURE);
+      goto bail;
   }
 
@@ -231,6 +251,5 @@
     if (dspam_attach(CTX2, NULL)) {
       LOG (LOG_WARNING, "unable to attach dspam context");
-      dspam_destroy(open_ctx);
-      exit(EXIT_FAILURE);
+      goto bail;
     }
 
@@ -261,5 +280,17 @@
 
   dspam_shutdown_driver ();
+  _ds_destroy_attributes(agent_config);
+  nt_destroy(users);
   exit (EXIT_SUCCESS);
+
+bail:
+
+  if (open_ctx)
+    dspam_destroy(open_ctx);
+  if (open_mtx)
+    dspam_destroy(open_mtx);
+  _ds_destroy_attributes(agent_config);
+  nt_destroy(users);
+  exit(EXIT_FAILURE);
 }
 
@@ -295,4 +326,6 @@
       nt_add(del, ss->signature);
     }
+    free(ss->data);
+    free(ss);
     ss = _ds_get_nextsignature (CTX);
   }
@@ -347,5 +380,6 @@
   struct lht *del;
   time_t t = time(NULL);
-  int delta;
+  int delta, toe = 0, tum = 0;
+  AGENT_PREF PTX;
                                                                                 
 #ifdef DEBUG
@@ -354,4 +388,23 @@
 #endif
 
+  PTX = _ds_pref_load(agent_config, CTX->username, _ds_read_attribute(agent_config, 
"Home"));
+                                                                                
+  if (PTX == NULL || PTX[0] == 0)
+    PTX = pref_config();
+                                                                                
+  if (!strcasecmp(_ds_pref_val(PTX, "trainingMode"), "toe")) {
+#ifdef DEBUG
+    printf("Limiting unused token purges for user %s - TOE Training Mode Set\n", 
CTX->username);
+#endif
+    toe = 1;
+  }
+
+  if (!strcasecmp(_ds_pref_val(PTX, "trainingMode"), "tum")) {
+#ifdef DEBUG
+    printf("Limiting unused token purges for user %s - TUM Training Mode Set\n", 
CTX->username);
+#endif
+    tum = 1;
+  }
+
   del = lht_create(1543);
   if (del == NULL)
@@ -361,6 +414,7 @@
   {
     delta = (((t - sr->last_hit) / 60) / 60) / 24;
-    if (any == 0 || delta > any)
+    if (!toe && (any == 0 || delta > any))
     { 
+      if (!tum || sr->innocent_hits + sr->spam_hits < 50)
       lht_hit(del, sr->token, "");
     }
@@ -401,4 +455,5 @@
   if (open_mtx != NULL)
     dspam_destroy (open_mtx);
+  _ds_destroy_attributes(agent_config);
   exit (EXIT_SUCCESS);
 }

Index: dspam_dump.c
===================================================================
RCS file: /cvsroot/mahogany/M/lib/dspam/tools/dspam_dump.c,v
retrieving revision 1.1.3.5
retrieving revision 1.2
diff -b -u -2 -r1.1.3.5 -r1.2
--- dspam_dump.c        23 Oct 2004 15:57:22 -0000      1.1.3.5
+++ dspam_dump.c        23 Oct 2004 16:13:02 -0000      1.2
@@ -68,9 +68,7 @@
   int r, sql = 0, i;
   char *username = NULL, *token = NULL;
-#ifndef _WIN32
 #ifdef TRUSTED_USER_SECURITY
   struct passwd *p = getpwuid (getuid ());
 #endif
-#endif
 
   /* Read dspam.conf */
@@ -87,5 +85,4 @@
   }
 
-#ifndef WIN32
 #ifdef TRUSTED_USER_SECURITY
   if (!_ds_match_attribute(agent_config, "Trust", p->pw_name) && p->pw_uid) {
@@ -94,9 +91,10 @@
   }
 #endif
-#endif
 
   open_ctx = NULL;
   signal (SIGINT, dieout);
+#ifndef _WIN32
   signal (SIGPIPE, dieout);
+#endif
   signal (SIGTERM, dieout);
 

Index: dspam_stats.c
===================================================================
RCS file: /cvsroot/mahogany/M/lib/dspam/tools/dspam_stats.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -b -u -2 -r1.4 -r1.5
--- dspam_stats.c       2 Oct 2004 13:32:46 -0000       1.4
+++ dspam_stats.c       23 Oct 2004 16:13:02 -0000      1.5
@@ -1,5 +1,7 @@
+/* $Id$ */
+
 /*
  DSPAM
- COPYRIGHT (C) 2003 NETWORK DWEEBS CORPORATION
+ COPYRIGHT (C) 2002-2004 NETWORK DWEEBS CORPORATION
 
 This program is free software; you can redistribute it and/or
@@ -39,5 +41,6 @@
 
 #include "libdspam.h"
-#include "../read_config.h"
+#include "read_config.h"
+#include "language.h"
 
 #define TSYNTAX        "syntax: dspam_stats [username]"
@@ -54,5 +57,5 @@
 main (int argc, char **argv)
 {
-  int ch,i;
+  int ch,i,users = 0;
 #ifndef HAVE_GETOPT
   int optind = 1;
@@ -70,10 +73,11 @@
   agent_config = read_config(NULL);
   if (!agent_config) {
-    report_error("Unable to read configuration");
+    report_error(ERROR_READ_CONFIG);
     exit(EXIT_FAILURE);
   }
                                                                                 
   if (!_ds_read_attribute(agent_config, "Home")) {
-    report_error("DSPAM Home must be defined in dspam.conf");
+    report_error(ERROR_DSPAM_HOME);
+    _ds_destroy_attributes(agent_config);
     exit(EXIT_FAILURE);
   }
@@ -81,6 +85,7 @@
 #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");
+  if (!_ds_match_attribute(agent_config, "Trust", p->pw_name) && p->pw_uid) {
+    fprintf(stderr, ERROR_TRUSTED_MODE "\n");
+    _ds_destroy_attributes(agent_config);
     exit(EXIT_FAILURE);
   }
@@ -88,4 +93,18 @@
 #endif
 
+  for(i=0;i<argc;i++) {
+                                                                                
+    if (!strncmp (argv[i], "--profile=", 10))
+    {
+      if (!_ds_match_attribute(agent_config, "Profile", argv[i]+10)) {
+        report_error_printf(ERROR_NO_SUCH_PROFILE, argv[i]+10);
+        _ds_destroy_attributes(agent_config);
+        exit(EXIT_FAILURE);
+      } else {
+        _ds_overwrite_attribute(agent_config, "DefaultProfile", argv[i]+10);
+      }
+      break;
+    }
+  }
 
   open_ctx = open_mtx = NULL;
@@ -134,19 +153,18 @@
   argc -= optind;
 
-  if (argc < 1)
-  {
-    /* if no arguments given, process everything */
-    process_all_users ();
-  }
-  else
-  {
     /* process arguments */
     for (i=0; i < argc; i++)
     {
+      if (strncmp(argv[i], "--", 2)) {
         stat_user(argv[i]);
+        users++;
     }
   }
 
+  if (!users)
+    process_all_users ();
+
   dspam_shutdown_driver ();
+  _ds_destroy_attributes(agent_config);
   exit (EXIT_SUCCESS);
 }
@@ -163,5 +181,5 @@
   {
     fprintf (stderr, "Could not initialize context: %s\n", strerror (errno));
-    exit (EXIT_FAILURE);
+    return EFAILURE;
   }
 
@@ -169,5 +187,6 @@
   if (dspam_attach(CTX, NULL)) {
     LOG (LOG_WARNING, "unable to attach dspam context");
-    exit(EXIT_FAILURE);
+    dspam_destroy(CTX);
+    return EFAILURE;
   }
 
@@ -260,4 +279,5 @@
   if (open_mtx != NULL)
     dspam_destroy (open_mtx);
+  _ds_destroy_attributes(agent_config);
   exit (EXIT_SUCCESS);
 }
@@ -272,4 +292,5 @@
       \t-h: print this message\n\
       \t-H: print stats in \"human friendly\" format\n");
-  exit(1);
+  _ds_destroy_attributes(agent_config);
+  exit(EXIT_FAILURE);
 }

--- .cvsignore 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