OSSP CVS Repository

ossp - Check-in [1942]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1942
Date: 2002-Mar-04 16:54:28 (local)
2002-Mar-04 15:54:28 (UTC)
User:thl
Branch:
Comment: Integration done replacing headervalue with new headerrule stuff. This version is v1.2a3 and runs live on visp.engelschall.com
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/00TODO      1.55 -> 1.56     0 inserted, 18 deleted
ossp-pkg/lmtp2nntp/README      1.16 -> 1.17     1 inserted, 1 deleted
ossp-pkg/lmtp2nntp/example.conf      1.15 -> 1.16     22 inserted, 0 deleted
ossp-pkg/lmtp2nntp/fixme.h      1.19 -> 1.20     4 inserted, 6 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_config.c      1.63 -> 1.64     7 inserted, 7 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_main.c      1.45 -> 1.46     10 inserted, 26 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_version.c      1.2 -> 1.3     9 inserted, 9 deleted
ossp-pkg/lmtp2nntp/test.sh      1.12 -> 1.13     6 inserted, 6 deleted

ossp-pkg/lmtp2nntp/00TODO 1.55 -> 1.56

--- 00TODO       2002/02/13 16:25:38     1.55
+++ 00TODO       2002/03/04 15:54:28     1.56
@@ -101,24 +101,6 @@
 
   -h [pri]:[regex]:header:[val]
 
-  # merge values from duplicate headers and separte them with "comma space"
-  -h :(Reply-To|To|Cc|Bcc):$0: [%{$0[#]}%{$0[#+1]:+, }]
-
-  # keep only first value from duplicate headers
-  -h :(X-Firstonly):$0: %{$0[0]}
-
-  # replace empty Subject with text "None"
-  -h :Subject: %{$Subject:-None}
-
-  # create Message-ID if omitted or illegal (<> single @)
-  -h :Messageid: %{messagid:s/^([^@+@[^@]+)$/<$1/:s/^[^<].*$/%{tool.createmessageid}/}
-
-  # append a header
-  -h ::X-Append: Tail
-
-  # remove a header (empty value)
-  -h ::X-Delete:
-
   foreach rule {
       if (rule has regex) {
           foreach header {


ossp-pkg/lmtp2nntp/README 1.16 -> 1.17

--- README       2001/12/31 15:15:36     1.16
+++ README       2002/03/04 15:54:28     1.17
@@ -7,7 +7,7 @@
                   |_|                        |_|    
 
   OSSP lmtp2nntp - Mail to News Gateway
-  Version 1.2a2 (31-Dec-2001)
+  Version 1.2a3 (04-Mar-2002)
 
   ABSTRACT
 


ossp-pkg/lmtp2nntp/example.conf 1.15 -> 1.16

--- example.conf 2002/01/31 15:54:53     1.15
+++ example.conf 2002/03/04 15:54:28     1.16
@@ -53,3 +53,25 @@
 version                                         #see -v aka --version
 newsgroup       "test"
 newsgroup       "alt.test"                      #see man page for information about newsgroup
+
+
+        ### CRUCIAL GATEWAY HEADER REWRITE RULES ###
+
+# merge values from duplicate headers and separte them with "comma space"
+headerrule 500:(Reply-To|To|Cc|Bcc):$0: [%{$0[#]}%{$0[#+1]:+, }]
+
+# keep only first value from duplicate headers
+headerrule 510:(X-Firstonly):$0: %{$0[0]}
+
+# replace empty Subject with text "None"
+headerrule 520:Subject: %{$Subject:-None}
+
+# create Message-ID if omitted or illegal (<> single @)
+headerrule 530:Messageid: %{messagid:s/^([^@+@[^@]+)$/<$1/:s/^[^<].*$/%{tool.createmessageid}/}
+
+# append a header
+headerrule 540::X-Append: Tail
+
+# remove a header (empty value)
+headerrule 550::X-Delete:
+


ossp-pkg/lmtp2nntp/fixme.h 1.19 -> 1.20

--- fixme.h      2002/02/28 12:57:55     1.19
+++ fixme.h      2002/03/04 15:54:28     1.20
@@ -67,13 +67,7 @@
     char           *option_operationmodefakestatus;
     char           *option_operationmodefakedsn;
     int             option_maxmessagesize;
-
     headerrule_t   *option_firstheaderrule;
-    /* FIXME obsolete */
-    char           *azHeaderValuePairs;
-    size_t          asHeaderValuePairs;
-
-
     int             option_timeout_lmtp_accept;
     int             option_timeout_lmtp_read;
     int             option_timeout_lmtp_write;
@@ -128,4 +122,8 @@
     OPERATIONMODE_FEED
 };
 
+void msg_headermatrixbuildup(msg_t *msg);
+void msg_headermatrixteardwn(msg_t *msg);
+void headerrewrite(lmtp2nntp_t *ctx);
+
 #endif /* __FIXME_H__ */


ossp-pkg/lmtp2nntp/lmtp2nntp_config.c 1.63 -> 1.64

--- lmtp2nntp_config.c   2002/02/28 15:57:09     1.63
+++ lmtp2nntp_config.c   2002/03/04 15:54:28     1.64
@@ -104,10 +104,6 @@
     return L2_OK;
 }
 
-static void msg_headermatrixbuildup(msg_t *msg);
-static void msg_headermatrixteardwn(msg_t *msg);
-static void headerrewrite(lmtp2nntp_t *ctx);
-
 static var_syntax_t syntax_regex = {
     '\\',         /* escape        */ 
     '$',          /* varinit       */ 
@@ -1250,7 +1246,7 @@
     return rc;
 }
 
-static void msg_headermatrixbuildup(msg_t *msg)
+void msg_headermatrixbuildup(msg_t *msg)
 {
     ex_t ex;
     volatile headerdata_t *hdNew = NULL;
@@ -1313,7 +1309,7 @@
     }
 }
 
-static void msg_headermatrixteardwn(msg_t *msg)
+void msg_headermatrixteardwn(msg_t *msg)
 {
     ex_t ex;
     try {
@@ -1351,7 +1347,7 @@
     }
 }
 
-static void headerrewrite(lmtp2nntp_t *ctx)
+void headerrewrite(lmtp2nntp_t *ctx)
 {
     headerrule_t *hrI;
     headerdata_t *hdI, *hdNew;
@@ -1360,6 +1356,10 @@
     int            ovec[OVECSIZE];
     var_rc_t rc; char *cp; //FIXME what a bad name, it's not the returncode of this function
 
+    /* short circuit in case no headerrules were set up */
+    if (ctx->option_firstheaderrule == NULL)
+        return;
+
     { //FIXME debug code block
         int i;
         headerrule_t *hrD;


ossp-pkg/lmtp2nntp/lmtp2nntp_main.c 1.45 -> 1.46

--- lmtp2nntp_main.c     2002/02/28 15:57:09     1.45
+++ lmtp2nntp_main.c     2002/03/04 15:54:28     1.46
@@ -368,8 +368,6 @@
     ctx->option_operationmodefakedsn    = NULL;
     ctx->option_maxmessagesize = 0;
     ctx->option_firstheaderrule = NULL;
-    ctx->azHeaderValuePairs = NULL; //FIXME obsolete
-    ctx->asHeaderValuePairs = 0;    //FIXME obsolete
     ctx->option_timeout_lmtp_accept  = 0;
     ctx->option_timeout_lmtp_read    = 0;
     ctx->option_timeout_lmtp_write   = 0;
@@ -437,7 +435,6 @@
     (void)option_create(&o, ctx->val); /* FIXME */
     (void)option_parse(o, argc, argv);
     (void)config_context(ctx);
-    CU(0); //FIXME
 
     if (getuid() != ctx->option_uid) {
         if (setuid(ctx->option_uid) == -1) {
@@ -676,8 +673,7 @@
         sa_addr_destroy(ctx->saaServerbind);
     if (ctx->option_restrictheader != NULL)
         free(ctx->option_restrictheader);
-    if (ctx->azHeaderValuePairs != NULL)
-        free(ctx->azHeaderValuePairs);
+    //FIXME if (ctx->azHeaderValuePairs != NULL) free(ctx->azHeaderValuePairs); what about headerrules
     if (ctx->option_pidfile != NULL)
         free(ctx->option_pidfile);
     if (ctx->progname != NULL)
@@ -1476,22 +1472,11 @@
         }
     }
 
-    /* Optionally add command line specified Header/Value Pairs
-     */
-    log0(ctx, TRACE, "adding header/value pairs");
-
-    cp = NULL;
-    while ((cp = argz_next(ctx->azHeaderValuePairs, ctx->asHeaderValuePairs, cp)) != NULL) {
-        var_rc_t var_rc;
-        char *res_ptr;
-        if ((var_rc = var_expand(ctx->config_varctx, cp, strlen(cp), &res_ptr, NULL, TRUE)) != VAR_OK) {
-            log3(ctx, ERROR, "expansion of '%s' failed: %s (%d)", cp, var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc);
-            continue;
-        }
-        log1(ctx, DEBUG, "adding expanded header: \"%s\"", res_ptr);
-        argz_add(&ctx->msg->azHeaders, &ctx->msg->asHeaders, res_ptr);
-        free(res_ptr);
-    }
+    /* rewrite headers */
+    log0(ctx, TRACE, "appying header rewrite rules");
+    msg_headermatrixbuildup(ctx->msg);
+    headerrewrite(ctx);
+    msg_headermatrixteardwn(ctx->msg);
 
     /*  RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS   554 Transaction failed
      *  RFC1893 2. Status Codes                         5.X.X   Permanent Failure
@@ -1616,11 +1601,10 @@
         for (i = 0; i < ctx->nns; i++) {
             if (ctx->pns[i].rc != NNTP_OK) {
                 str_format(errorstring, sizeof(errorstring), 
-                "${option.destination}[${i}] returned %s\n" /*FIXME*/
-                "${option.destination}[${i}] lastresp \"%s\"",  /*FIXME*/
-                i,
-                nntp_error(ctx->pns[i].rc), 
-                nntp_lastresp(ctx->pns[i].nntp));
+                "${option.destination}[%d] returned %s\n" /*FIXME*/
+                "${option.destination}[%d] lastresp \"%s\"",  /*FIXME*/
+                i, nntp_error(ctx->pns[i].rc), 
+                i, nntp_lastresp(ctx->pns[i].nntp));
                 argz_add(&azErr, &asErr, errorstring);
             }
         }


ossp-pkg/lmtp2nntp/lmtp2nntp_version.c 1.2 -> 1.3

--- lmtp2nntp_version.c  2001/12/31 12:03:09     1.2
+++ lmtp2nntp_version.c  2002/03/04 15:54:28     1.3
@@ -8,7 +8,7 @@
 #ifndef _LMTP2NNTP_VERSION_C_
 #define _LMTP2NNTP_VERSION_C_
 
-#define LMTP2NNTP_VERSION 0x102002
+#define LMTP2NNTP_VERSION 0x102003
 
 typedef struct {
     const int   v_hex;
@@ -32,14 +32,14 @@
 #undef  _LMTP2NNTP_VERSION_C_AS_HEADER_
 
 lmtp2nntp_version_t lmtp2nntp_version = {
-    0x102002,
-    "1.2a2",
-    "1.2a2 (31-Dec-2001)",
-    "This is OSSP lmtp2nntp, Version 1.2a2 (31-Dec-2001)",
-    "OSSP lmtp2nntp 1.2a2 (31-Dec-2001)",
-    "OSSP lmtp2nntp/1.2a2",
-    "@(#)OSSP lmtp2nntp 1.2a2 (31-Dec-2001)",
-    "$Id: OSSP lmtp2nntp 1.2a2 (31-Dec-2001) $"
+    0x102003,
+    "1.2a3",
+    "1.2a3 (04-Mar-2002)",
+    "This is OSSP lmtp2nntp, Version 1.2a3 (04-Mar-2002)",
+    "OSSP lmtp2nntp 1.2a3 (04-Mar-2002)",
+    "OSSP lmtp2nntp/1.2a3",
+    "@(#)OSSP lmtp2nntp 1.2a3 (04-Mar-2002)",
+    "$Id: OSSP lmtp2nntp 1.2a3 (04-Mar-2002) $"
 };
 
 #endif /* _LMTP2NNTP_VERSION_C_AS_HEADER_ */


ossp-pkg/lmtp2nntp/test.sh 1.12 -> 1.13

--- test.sh      2002/02/07 13:39:38     1.12
+++ test.sh      2002/03/04 15:54:28     1.13
@@ -16,10 +16,10 @@
 Message-Id: <200108141251.f7ECpmn74812@dev.de.cw.net>
 From: Thomas Lotterer <Thomas.Lotterer@example.com>
 Received: from cw.example.com (cw.example.com [10.1.1.32])
-    by gateway.example.com (8.9.2/8.9.2/$Revision: 1.12 $) with SMTP id NAA08840
+    by gateway.example.com (8.9.2/8.9.2/$Revision: 1.13 $) with SMTP id NAA08840
     for <thomas.lotterer@gateway.example.com>; Mon, 2 Apr 2001 13:20:25 +0200 (MET DST)
 Received: from history (history.example.org [195.143.102.41])
-    by cw.example.com (8.11.0/8.11.0/$Revision: 1.12 $) with ESMTP id f32BKPb12235
+    by cw.example.com (8.11.0/8.11.0/$Revision: 1.13 $) with ESMTP id f32BKPb12235
     for <thomas.lotterer@example.com>; Mon, 2 Apr 2001 13:20:25 +0200
 Received: from example.org (littlemua.example.org [195.143.103.160])
         by history (8.8.8/8.8.8) with ESMTP id LAA12678;
@@ -126,7 +126,7 @@
 if [ 1 -eq `egrep <${STDOUT} -- '-c.*--client'          | wc -l` ]; then RC="${RC}-c "; fi
 if [ 1 -eq `egrep <${STDOUT} -- '-d.*--destination'     | wc -l` ]; then RC="${RC}-d "; fi
 if [ 1 -eq `egrep <${STDOUT} -- '-g.*--groupmode'       | wc -l` ]; then RC="${RC}-g "; fi
-if [ 1 -eq `egrep <${STDOUT} -- '-h.*--headervalue'     | wc -l` ]; then RC="${RC}-h "; fi
+if [ 1 -eq `egrep <${STDOUT} -- '-h.*--headerrule'      | wc -l` ]; then RC="${RC}-h "; fi
 if [ 1 -eq `egrep <${STDOUT} -- '-i.*--include'         | wc -l` ]; then RC="${RC}-i "; fi
 if [ 1 -eq `egrep <${STDOUT} -- '--timeoutlmtp'         | wc -l` ]; then RC="${RC}--timeoutlmtp "; fi
 if [ 1 -eq `egrep <${STDOUT} -- '--timeoutlmtpaccept'   | wc -l` ]; then RC="${RC}--timeoutlmtpaccept "; fi
@@ -283,11 +283,11 @@
 echon "checking whether -h option adds header/value pair ... "
 prolog
 newmsg
-./lmtp2nntp <${STDIN} -b - -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -h "X-Gateway: added it!" ${LOG} -m "${MFILT}" -n ${NODE} -s 1500 --timeoutnntpconnect=1 ${GROUP} >${STDOUT} 2>${STDERR}
+./lmtp2nntp <${STDIN} -b - -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -h "::X-Gateway:added it!" ${LOG} -m "${MFILT}" -n ${NODE} -s 1500 --timeoutnntpconnect=1 ${GROUP} >${STDOUT} 2>${STDERR}
 RC="";
 if [ 1 -eq `egrep <${STDOUT} '^220[- ]LMTP Service ready'       | wc -l` ]; then RC="${RC}init "; fi
-if [ 1 -eq `egrep <${L2FILE} 'adding.*header: "X-Gateway:"'     | wc -l` ]; then RC="${RC}head "; fi
-if [ 1 -eq `egrep <${L2FILE} 'adding.*header: "added it!"'      | wc -l` ]; then RC="${RC}val. "; fi
+if [ 1 -eq `egrep <${L2FILE} 'appending header X-Gateway:'      | wc -l` ]; then RC="${RC}head "; fi
+if [ 1 -eq `egrep <${L2FILE} 'header=X-Gateway.*data=added it!' | wc -l` ]; then RC="${RC}val. "; fi
 if [ 1 -eq `egrep <${L2FILE} 'verbatim.*"X-Gateway: added it!"' | wc -l` ]; then RC="${RC}pair "; fi
 if [ "${RC}" != "init head val. pair " ]; then
     echo "NO (got ${RC})"

CVSTrac 2.0.1