OSSP CVS Repository

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

Check-in Number: 1185
Date: 2001-Oct-15 12:13:50 (local)
2001-Oct-15 10:13:50 (UTC)
User:thl
Branch:
Comment: Applied Ralf's "Approved:" header patch but in a more general form which allows any kind and any number of headers to be inserted.
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/lmtp2nntp.c      1.90 -> 1.91     41 inserted, 1 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp.pod      1.31 -> 1.32     7 inserted, 0 deleted
ossp-pkg/lmtp2nntp/test.sh      1.5 -> 1.6     4 inserted, 8 deleted

ossp-pkg/lmtp2nntp/lmtp2nntp.c 1.90 -> 1.91

--- lmtp2nntp.c  2001/10/12 13:24:44     1.90
+++ lmtp2nntp.c  2001/10/15 10:13:50     1.91
@@ -143,6 +143,8 @@
     char           *option_operationmodefakestatus;
     char           *option_operationmodefakedsn;
     int             option_maxmessagesize;
+    char           *azHeaderValuePairs;
+    size_t          asHeaderValuePairs;
     int             option_timeout_lmtp_accept;
     int             option_timeout_lmtp_read;
     int             option_timeout_lmtp_write;
@@ -218,6 +220,7 @@
             "[-c addr[:port]] "
             "[-d addr[:port][,addr[:port], ...]] "
             "[-g groupmode] "
+            "[-h header:value] "
             "[-l level[:logfile]] "
             "[-m mailfrom] "
             "[-n nodename] "
@@ -403,6 +406,8 @@
     char         *cpAddr;
     char         *cpPrefixLen;
     struct passwd *sPasswd;
+    char         *cpHeadername;
+    char         *cpHeadervalue;
 
     /* drop effective uid/gid priviledges */
     seteuid(getuid());
@@ -429,6 +434,8 @@
     ctx->option_operationmodefakestatus = "553";   /* Requested action not taken: mailbox name not allowed */
     ctx->option_operationmodefakedsn    = "5.7.1"; /* Delivery not authorized, message refused */
     ctx->option_maxmessagesize = 8 * 1024 * 1024;
+    ctx->azHeaderValuePairs = NULL;
+    ctx->asHeaderValuePairs = 0;
     ctx->option_timeout_lmtp_accept = 0;
     ctx->option_timeout_lmtp_read = 10;
     ctx->option_timeout_lmtp_write = 10;
@@ -485,7 +492,7 @@
      */
 
     /* read in the arguments */
-    while ((i = getopt(argc, argv, "C:DKP:Va:b:c:d:g:l:m:n:o:s:t:u:v")) != -1) {
+    while ((i = getopt(argc, argv, "C:DKP:Va:b:c:d:g:h:l:m:n:o:s:t:u:v")) != -1) {
         switch (i) {
             case 'C': /*POD [B<-C> I<childsmax>] */
                 ctx->option_childsmax = atoi(optarg);
@@ -693,6 +700,28 @@
                     CU(ERR_EXECUTION);
                 }
                 break;
+            case 'h': /*POD [B<-h> I<header>:<value>] */
+                cpHeadername = strdup(optarg);
+                if ((cp = strrchr(cpHeadername, ':')) == NULL) {
+                    free(cpHeadername);
+                    fprintf(stderr, "%s:Error: header \"%s\" for -h option not terminated with colon\n", 
+                            ctx->progname, cpHeadername);
+                    CU(ERR_EXECUTION);
+                }
+                cp++;
+                if (*cp == NUL) {
+                    free(cpHeadername);
+                    fprintf(stderr, "%s:Error: header \"%s\" for -h option has no value\n", 
+                            ctx->progname, cpHeadername);
+                    CU(ERR_EXECUTION);
+                }
+                cpHeadervalue = strdup(cp);
+                *cp = NUL;
+                argz_add(&ctx->azHeaderValuePairs, &ctx->asHeaderValuePairs, cpHeadername);
+                argz_add(&ctx->azHeaderValuePairs, &ctx->asHeaderValuePairs, cpHeadervalue);
+                free(cpHeadervalue);
+                free(cpHeadername);
+                break;
             case 'l': /*POD [B<-l> I<level>[:I<logfile>]] */
                 if ((cp = strrchr(optarg, ':')) != NULL) {
                     *cp++ = NUL;
@@ -1238,6 +1267,8 @@
         sa_destroy(ctx->saAltio);
     if (ctx->saaAltio)
         sa_addr_destroy(ctx->saaAltio);
+    if (ctx->azHeaderValuePairs != NULL)
+        free(ctx->azHeaderValuePairs);
     if (ctx->option_pidfile != NULL)
         free(ctx->option_pidfile);
     if (ctx->option_logfile != NULL)
@@ -2002,6 +2033,15 @@
         }
     }
 
+    /* Optionally add command line specified Header/Value Pairs
+     */
+    if ((ctx->asHeaderValuePairs >= 1) && ((ctx->asHeaderValuePairs & 1) == 0)) {
+        cp = NULL;
+        while ((cp = argz_next(ctx->azHeaderValuePairs, ctx->asHeaderValuePairs, cp)) != NULL) {
+            argz_add(&ctx->msg->azHeaders, &ctx->msg->asHeaders, cp);
+        }
+    }
+
     /*  RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS   554 Transaction failed
      *  RFC1893 2. Status Codes                         5.X.X   Permanent Failure
      *  RFC1893 3.5 Network and Routing Status          X.6.5   Conversion Failed


ossp-pkg/lmtp2nntp/lmtp2nntp.pod 1.31 -> 1.32

--- lmtp2nntp.pod        2001/10/12 13:23:52     1.31
+++ lmtp2nntp.pod        2001/10/15 10:13:50     1.32
@@ -43,6 +43,7 @@
 [B<-c> I<addr>[I<:port>]]
 [B<-d> I<addr>[I<:port>][,I<addr>[I<:port>], ...]]
 [B<-g> I<groupmode>]
+[B<-h> I<header>:<value>]
 [B<-l> I<level>[:I<logfile>]]
 [B<-m> I<mailfrom>]
 [B<-n> I<nodename>]
@@ -70,6 +71,12 @@
 
 =over 4
 
+=item B<-h> I<header>:<value>
+
+Header with value to to be inserted into message before delivery.  This option
+can be specified more than once.  Useful for specifiying an moderator Email
+address to all outgoing news messages by applying an "Approved:" header.
+
 =item B<-C> I<childsmax>
 
 Childs the daemon spawns at maximum. Default is 10.


ossp-pkg/lmtp2nntp/test.sh 1.5 -> 1.6

--- test.sh      2001/10/12 14:02:57     1.5
+++ test.sh      2001/10/15 10:13:50     1.6
@@ -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.5 $) with SMTP id NAA08840
+    by gateway.example.com (8.9.2/8.9.2/$Revision: 1.6 $) 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.5 $) with ESMTP id f32BKPb12235
+    by cw.example.com (8.11.0/8.11.0/$Revision: 1.6 $) 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;
@@ -100,15 +100,11 @@
 echo "yes"
 
 echon "checking whether -? usage option works ... "
-# expected typical output: USAGE: ./lmtp2nntp
-# [-D] [-K] [-P pidfile] [-a addr/mask[,addr/mask[,...]] [-b
-# -|path|addr[:port]] [-c addr[:port]] [-d addr[:port][,addr[:port], ...]] [-g
-# groupmode] [-l level[:logfile]] [-m mailfrom] [-n nodename] [-o operationmode]
-# [-s size] [-t name=sec[,name=sec[,...]] [-v] newsgroup [newsgroup ...] 
+# expected typical output see ./lmtp2nntp -?
 prolog
 newmsg
 ./lmtp2nntp -? >${STDOUT} 2>${STDERR}
-RC=`cat ${STDERR} | egrep -- '-C.*-D.*-K.*-P.*-V.*-a.*-b.*-d.*-g.*-l.*-m.*-n.*-o.*-s.*-t.*-v.*newsgroup' | wc -l`
+RC=`cat ${STDERR} | egrep -- '-C.*-D.*-K.*-P.*-V.*-a.*-b.*-d.*-g.*-h.*-l.*-m.*-n.*-o.*-s.*-t.*-v.*newsgroup' | wc -l`
 if [ ${RC} -ne 1 -o -s ${STDOUT} ]; then
     echo "NO (got ${RC})"
     exit 1;

CVSTrac 2.0.1