OSSP CVS Repository

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

Check-in Number: 921
Date: 2001-Sep-10 16:11:33 (local)
2001-Sep-10 14:11:33 (UTC)
User:thl
Branch:
Comment: fake mode now supports NTTP-less setups
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/lmtp2nntp.c      1.48 -> 1.49     58 inserted, 27 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp.pod      1.18 -> 1.19     12 inserted, 10 deleted
ossp-pkg/lmtp2nntp/nntp.c      1.23 -> 1.24     1 inserted, 0 deleted
ossp-pkg/lmtp2nntp/nntp.h      1.10 -> 1.11     1 inserted, 0 deleted

ossp-pkg/lmtp2nntp/lmtp2nntp.c 1.48 -> 1.49

--- lmtp2nntp.c  2001/09/10 12:49:48     1.48
+++ lmtp2nntp.c  2001/09/10 14:11:33     1.49
@@ -791,15 +791,19 @@
      *  RFC1893 2. Status Codes                         4.X.X   Persistent Transient Failure
      *  RFC1893 3.5 Network and Routing Status          X.3.5   System incorrectly configured
      */
-    log0(ctx, TRACE, "check if at least one NNTP service was successfully configured");
-    if (ctx->nsc == 0) {
-        res.statuscode = "451";
-        res.dsncode    = "4.3.5";
-        res.statusmsg  = "No valid NNTP services configured.";
-        CU(LMTP_OK);
+    if (ctx->option_deliverymode != DELIVERYMODE_FAKE) {
+        log0(ctx, TRACE, "check if at least one NNTP service was successfully configured");
+        if (ctx->nsc == 0) {
+            res.statuscode = "451";
+            res.dsncode    = "4.3.5";
+            res.statusmsg  = "No valid NNTP services configured.";
+            CU(LMTP_OK);
+        }
     }
 
     log0(ctx, TRACE, "try to establish a session to any configured NNTP services");
+    if (ctx->option_deliverymode == DELIVERYMODE_FAKE)
+        log0(ctx, NOTICE, "NNTP running in fake mode, network connections will be executed but result is ignored");
     i = 0;
     do {
         log1(ctx, DEBUG, "trying ns[%d]", i);
@@ -870,17 +874,22 @@
         }
     } while (i < ctx->nsc);
 
-    /*  RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS   421 <domain> Service not available
-     *  RFC1893 2. Status Codes                         4.X.X   Persistent Transient Failure
-     *  RFC1893 3.5 Network and Routing Status          X.4.1   No answer from host
-     */
-    log0(ctx, DEBUG, "check if at least one NNTP session successfully established");
-    if (ctx->nsc == 0) {
-        log0(ctx, ERROR, "no NNTP session established");
-        res.statuscode = "421";
-        res.dsncode    = "4.4.1";
-        res.statusmsg  = "No NNTP session established.";
-        CU(LMTP_OK);
+    if (ctx->option_deliverymode == DELIVERYMODE_FAKE)
+        log1(ctx, NOTICE, "NNTP running in fake mode, network connections successfully established=%d but ignored", ctx->nsc);
+    else
+    {
+        /*  RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS   421 <domain> Service not available
+         *  RFC1893 2. Status Codes                         4.X.X   Persistent Transient Failure
+         *  RFC1893 3.5 Network and Routing Status          X.4.1   No answer from host
+         */
+        log0(ctx, DEBUG, "check if at least one NNTP session successfully established");
+        if (ctx->nsc == 0) {
+            log0(ctx, ERROR, "no NNTP session established");
+            res.statuscode = "421";
+            res.dsncode    = "4.4.1";
+            res.statusmsg  = "No NNTP session established.";
+            CU(LMTP_OK);
+        }
     }
         
     ctx->session.lhlo_seen = TRUE;
@@ -1463,6 +1472,7 @@
     for (i = 0; i < ctx->nsc; i++) {
         switch (ctx->option_deliverymode) {
             case DELIVERYMODE_FAKE:
+                ctx->ns[i].rc = NNTP_FAKE;
                 break;
             case DELIVERYMODE_POST:
                 ctx->ns[i].rc = nntp_post(ctx->ns[i].nntp, ctx->msg);
@@ -1483,16 +1493,37 @@
             bSuccess = NNTP_DEFER;
     }
 
-    str_format(errorstring, sizeof(errorstring), "%sdelivery of %s", 
-        ((ctx->option_deliverymode == DELIVERYMODE_FAKE) ? "fake " :
-         (ctx->option_deliverymode == DELIVERYMODE_POST) ? "post " :
-         (ctx->option_deliverymode == DELIVERYMODE_FEED) ? "feed " : ""), ctx->msg->cpMsgid);
-    if (bSuccess == NNTP_OK)
-        log2(ctx, NOTICE,  "%s %s", errorstring, "succeeded");
-    else if(bSuccess == NNTP_DEFER)
-        log2(ctx, WARNING, "%s %s", errorstring, "deferred");
-    else
-        log2(ctx, ERROR,   "%s %s", errorstring, "failed");
+    if (ctx->option_deliverymode == DELIVERYMODE_FAKE) {
+        str_format(errorstring, sizeof(errorstring),
+                   "NNTP running in fake mode, delivery of %s %s but delivery status forced to",
+                   ctx->msg->cpMsgid,
+                   ((bSuccess == NNTP_OK)    ? "succeeded" :
+                    (bSuccess == NNTP_DEFER) ? "deferred"  : "failed"));
+        switch (ctx->option_deliverymodefakestatus[0]) {
+            case '5':
+                bSuccess = NNTP_ERR_UNKNOWN;
+                log2(ctx, NOTICE, "%s %s", errorstring, "failed");
+                break;
+            case '4':
+                bSuccess = NNTP_DEFER;
+                log2(ctx, NOTICE, "%s %s", errorstring, "deferred");
+                break;
+            default:
+                bSuccess = NNTP_OK;
+                log2(ctx, NOTICE, "%s %s", errorstring, "succeeded");
+                break;
+        }
+    } else {
+        str_format(errorstring, sizeof(errorstring), "%sdelivery of %s", 
+            ((ctx->option_deliverymode == DELIVERYMODE_POST) ? "post " :
+             (ctx->option_deliverymode == DELIVERYMODE_FEED) ? "feed " : ""), ctx->msg->cpMsgid);
+        if (bSuccess == NNTP_OK)
+            log2(ctx, NOTICE,  "%s %s", errorstring, "succeeded");
+        else if(bSuccess == NNTP_DEFER)
+            log2(ctx, WARNING, "%s %s", errorstring, "deferred");
+        else
+            log2(ctx, ERROR,   "%s %s", errorstring, "failed");
+    }
 
     /*  RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS   250 Requested mail action okay, completed
      *                                                  451 Requested action aborted: local error in processing


ossp-pkg/lmtp2nntp/lmtp2nntp.pod 1.18 -> 1.19

--- lmtp2nntp.pod        2001/09/07 13:53:16     1.18
+++ lmtp2nntp.pod        2001/09/10 14:11:33     1.19
@@ -72,16 +72,18 @@
 
 =item B<-d> I<deliverymode>
 
-Possible values for I<deliverymode> are C<post>, C<feed> or a string used to
-fake a LMTP return code and DSN in "LLL/D.D.D" format. The slash is replaced
-by a space internally. The default is "553/5.7.1" meaning "Requested action
-not taken: mailbox name not allowed/ Delivery not authorized, message
-refused". In C<post> mode articles are sent to the NNTP server(s) using POST
-command. Before posting, a duplicate check using STAT command is issued. In
-C<feed> mode articles are sent to the NNTP server(s) using IHAVE command.
-Specifying a return code/ DSN replaces the post/ feed logic by a noop and
-assumes the given string must be returned to the LMTP side. This is useful for
-debugging LMTP setups without engaging NNTP.
+Possible values for I<deliverymode> are C<post>, C<feed> or a string in
+"LLL/D.D.D" format used to fake a LMTP return code.  In C<post> mode articles
+are sent to the NNTP server(s) using POST command. Before posting, a duplicate
+check using STAT command is issued. In C<feed> mode articles are sent to the
+NNTP server(s) using IHAVE command.  Specifying a return code and DSN replaces
+the post/ feed logic by a noop and assumes the given string must be returned
+to the LMTP side.  The slash is replaced by a space internally. The default is
+"553/5.7.1" meaning "Requested action not taken: mailbox name not allowed/
+Delivery not authorized, message refused".  This is useful for debugging LMTP
+setups without engaging NNTP.  Fake mode makes it possible to run without any
+B<-h> option. However, if B<-h> option is given the NNTP client tries to
+connect but it's return codes are ignored.
 
 =item B<-g> I<groupmode>
 


ossp-pkg/lmtp2nntp/nntp.c 1.23 -> 1.24

--- nntp.c       2001/09/10 12:48:14     1.23
+++ nntp.c       2001/09/10 14:11:33     1.24
@@ -451,6 +451,7 @@
     else if (rc == NNTP_EOF         ) str = "NNTP: end of file";
     else if (rc == NNTP_TIMEOUT     ) str = "NNTP: timeout";
     else if (rc == NNTP_DEFER       ) str = "NNTP: transmission deferred";
+    else if (rc == NNTP_FAKE        ) str = "NNTP: fake status not real";
     else if (rc == NNTP_ERR_SYSTEM  ) str = "NNTP: see errno";
     else if (rc == NNTP_ERR_ARG     ) str = "NNTP: invalid argument";
     else if (rc == NNTP_ERR_OVERFLOW) str = "NNTP: buffer overflow";


ossp-pkg/lmtp2nntp/nntp.h 1.10 -> 1.11

--- nntp.h       2001/09/10 12:48:14     1.10
+++ nntp.h       2001/09/10 14:11:33     1.11
@@ -48,6 +48,7 @@
     NNTP_EOF,
     NNTP_TIMEOUT,
     NNTP_DEFER,
+    NNTP_FAKE,
     NNTP_ERR_SYSTEM,
     NNTP_ERR_ARG,
     NNTP_ERR_OVERFLOW,

CVSTrac 2.0.1