OSSP CVS Repository

ossp - Difference in ossp-pkg/lmtp2nntp/lmtp2nntp.c versions 1.48 and 1.49
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

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

CVSTrac 2.0.1