[exim-cvs] Transports: explicit errno values in returns

トップ ページ
このメッセージを削除
このメッセージに返信
著者: Exim Git Commits Mailing List
日付:  
To: exim-cvs
題目: [exim-cvs] Transports: explicit errno values in returns
Gitweb: https://git.exim.org/exim.git/commitdiff/6e0fddef0de4966abad739bed65d49e097651853
Commit:     6e0fddef0de4966abad739bed65d49e097651853
Parent:     377da0430697e6bcb8c48744eb5af4272a8f8075
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Thu Dec 5 14:18:07 2019 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Thu Dec 5 14:18:07 2019 +0000


    Transports: explicit errno values in returns
---
 src/src/exim_dbutil.c          |  2 +-
 src/src/macros.h               |  7 ++-----
 src/src/transports/autoreply.c | 21 ++++++++++-----------
 src/src/transports/pipe.c      |  4 ++--
 src/src/transports/smtp.c      |  2 +-
 test/log/0228                  |  2 +-
 6 files changed, 17 insertions(+), 21 deletions(-)


diff --git a/src/src/exim_dbutil.c b/src/src/exim_dbutil.c
index 80f6565..7b13859 100644
--- a/src/src/exim_dbutil.c
+++ b/src/src/exim_dbutil.c
@@ -332,7 +332,7 @@ if (asprintf(CSS &filename, "%s/%s", dirname, name) < 0) return NULL;
#else
filename = string_sprintf("%s/%s", dirname, name);
#endif
-EXIM_DBOPEN(filename, dirname, flags, 0, &(dbblock->dbptr));
+EXIM_DBOPEN(filename, dirname, flags, 0, &dbblock->dbptr);

 if (!dbblock->dbptr)
   {
diff --git a/src/src/macros.h b/src/src/macros.h
index e36c09c..a9653f4 100644
--- a/src/src/macros.h
+++ b/src/src/macros.h
@@ -550,11 +550,8 @@ table exim_errstrings[] in log.c */
 #define ERRNO_DATA4XX        (-46)   /* DATA gave 4xx error */
 #define ERRNO_PROXYFAIL      (-47)   /* Negotiation failed for proxy configured host */
 #define ERRNO_AUTHPROB       (-48)   /* Authenticator "other" failure */
-
-#ifdef SUPPORT_I18N
-# define ERRNO_UTF8_FWD      (-49)   /* target not supporting SMTPUTF8 */
-#endif
-                /* -50 free for re-use */
+#define ERRNO_UTF8_FWD       (-49)   /* target not supporting SMTPUTF8 */
+#define ERRNO_HOST_IS_LOCAL  (-50)   /* Transport refuses to talk to localhost */


/* These must be last, so all retry deferments can easily be identified */

diff --git a/src/src/transports/autoreply.c b/src/src/transports/autoreply.c
index 1aef02a..68f8d1f 100644
--- a/src/src/transports/autoreply.c
+++ b/src/src/transports/autoreply.c
@@ -433,10 +433,10 @@ if (oncelog && *oncelog != 0 && to)
     if (cache_fd < 0 || fstat(cache_fd, &statbuf) != 0)
       {
       addr->transport_return = DEFER;
+      addr->basic_errno = errno;
       addr->message = string_sprintf("Failed to %s \"once\" file %s when "
         "sending message from %s transport: %s",
-        (cache_fd < 0)? "open" : "stat", oncelog, tblock->name,
-          strerror(errno));
+        cache_fd < 0 ? "open" : "stat", oncelog, tblock->name, strerror(errno));
       goto END_OFF;
       }


@@ -489,6 +489,7 @@ if (oncelog && *oncelog != 0 && to)
     if (!dbm_file)
       {
       addr->transport_return = DEFER;
+      addr->basic_errno = errno;
       addr->message = string_sprintf("Failed to open %s file %s when sending "
         "message from %s transport: %s", EXIM_DBTYPE, oncelog, tblock->name,
         strerror(errno));
@@ -544,16 +545,13 @@ if (oncelog && *oncelog != 0 && to)


/* We are going to send a message. Ensure any requested file is available. */

-if (file)
+if (file && !(ff = Ufopen(file, "rb")) && !ob->file_optional)
   {
-  ff = Ufopen(file, "rb");
-  if (!ff && !ob->file_optional)
-    {
-    addr->transport_return = DEFER;
-    addr->message = string_sprintf("Failed to open file %s when sending "
-      "message from %s transport: %s", file, tblock->name, strerror(errno));
-    return FALSE;
-    }
+  addr->transport_return = DEFER;
+  addr->basic_errno = errno;
+  addr->message = string_sprintf("Failed to open file %s when sending "
+    "message from %s transport: %s", file, tblock->name, strerror(errno));
+  return FALSE;
   }


 /* Make a subprocess to send the message */
@@ -565,6 +563,7 @@ pid = child_open_exim(&fd);
 if (pid < 0)
   {
   addr->transport_return = DEFER;
+  addr->basic_errno = errno;
   addr->message = string_sprintf("Failed to create child process to send "
     "message from %s transport: %s", tblock->name, strerror(errno));
   DEBUG(D_transport) debug_printf("%s\n", addr->message);
diff --git a/src/src/transports/pipe.c b/src/src/transports/pipe.c
index 4386a9a..a16a197 100644
--- a/src/src/transports/pipe.c
+++ b/src/src/transports/pipe.c
@@ -686,8 +686,7 @@ else if (timezone_string != NULL && timezone_string[0] != 0)


 if (envlist)
   {
-  envlist = expand_cstring(envlist);
-  if (envlist == NULL)
+  if (!(envlist = expand_cstring(envlist)))
     {
     addr->transport_return = DEFER;
     addr->message = string_sprintf("failed to expand string \"%s\" "
@@ -702,6 +701,7 @@ while ((ss = string_nextinlist(&envlist, &envsep, big_buffer, big_buffer_size)))
    if (envcount > nelem(envp) - 2)
      {
      addr->transport_return = DEFER;
+     addr->basic_errno = E2BIG;
      addr->message = string_sprintf("too many environment settings for "
        "%s transport", tblock->name);
      return FALSE;
diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c
index dee546c..7ea079f 100644
--- a/src/src/transports/smtp.c
+++ b/src/src/transports/smtp.c
@@ -4925,7 +4925,7 @@ retry_non_continued:
         {
         for (address_item * addr = addrlist; addr; addr = addr->next)
           {
-          addr->basic_errno = 0;
+          addr->basic_errno = ERRNO_HOST_IS_LOCAL;
           addr->message = string_sprintf("%s transport found host %s to be "
             "local", tblock->name, host->name);
           }
diff --git a/test/log/0228 b/test/log/0228
index 646034c..7ae197d 100644
--- a/test/log/0228
+++ b/test/log/0228
@@ -1,3 +1,3 @@
 1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@??? U=CALLER P=local S=sss
 1999-03-02 09:44:33 10HmaX-0005vi-00 H=127.0.0.1 [127.0.0.1] Connection refused
-1999-03-02 09:44:33 10HmaX-0005vi-00 == abcd@??? R=all T=smtp defer (0): smtp transport found host ip4.ip4.ip4.ip4 to be local
+1999-03-02 09:44:33 10HmaX-0005vi-00 == abcd@??? R=all T=smtp defer (-50): smtp transport found host ip4.ip4.ip4.ip4 to be local