New: queuefile transport, under EXPERIMENTAL_QUEUEFILE
authorAndrew Colin Kissa <andrew@topdog.za.net>
Sat, 15 Oct 2016 17:33:31 +0000 (18:33 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Sat, 15 Oct 2016 17:33:31 +0000 (18:33 +0100)
28 files changed:
doc/doc-txt/NewStuff
doc/doc-txt/experimental-spec.txt
src/scripts/MakeLinks
src/src/EDITME
src/src/config.h.defaults
src/src/drtables.c
src/src/exim.c
src/src/functions.h
src/src/queue.c
src/src/transports/Makefile
src/src/transports/queuefile.c [new file with mode: 0644]
src/src/transports/queuefile.h [new file with mode: 0644]
test/confs/5900 [new file with mode: 0644]
test/confs/5901 [new file with mode: 0644]
test/confs/5902 [new file with mode: 0644]
test/log/5900 [new file with mode: 0644]
test/log/5901 [new file with mode: 0644]
test/log/5902 [new file with mode: 0644]
test/mail/5902.user1.5902 [new file with mode: 0644]
test/paniclog/5900 [new file with mode: 0644]
test/paniclog/5901 [new file with mode: 0644]
test/scripts/5900-queuefile-transport/5900 [new file with mode: 0644]
test/scripts/5900-queuefile-transport/5901 [new file with mode: 0644]
test/scripts/5900-queuefile-transport/5902 [new file with mode: 0644]
test/scripts/5900-queuefile-transport/REQUIRES [new file with mode: 0644]
test/stderr/5900 [new file with mode: 0644]
test/stderr/5901 [new file with mode: 0644]
test/stdout/5902 [new file with mode: 0644]

index 2e060cce2804dc27a82ef1eb7c77f41a23ae32b2..cca958f79a3b205ce7cd8349ed13d2fb15bcc1b5 100644 (file)
@@ -51,6 +51,9 @@ Version 4.88
 
 13. New built-in constants available for tls_dhparam and default changed.
 
 
 13. New built-in constants available for tls_dhparam and default changed.
 
+14. If built with EXPERIMENTAL_QUEUEFILE, a queuefile transport, for writing
+    out copies of the message spool files for use by 3rd-party scanners.
+
 
 Version 4.87
 ------------
 
 Version 4.87
 ------------
index 2e72def272bf92d384ad3fb6f5d7f201853a9736..5213d8be46f3c5577cca13c1884321121e0dc2e8 100644 (file)
@@ -1013,6 +1013,63 @@ ${lookup{$sender_address_domain}lmdb{/var/lib/baruwa/data/db/relaydomains.mdb}{$
 ${lookup{$sender_address_domain}lmdb{/var/lib/baruwa/data/db/relaydomains.mdb}}
 
 
 ${lookup{$sender_address_domain}lmdb{/var/lib/baruwa/data/db/relaydomains.mdb}}
 
 
+Queuefile transport
+-------------------
+Queuefile is a pseudo transport which does not perform final delivery.
+It simply copies the exim spool files out of the spool directory into
+an external directory retaining the exim spool format.
+
+The spool files can then be processed by external processes and then
+requeued into exim spool directories for final delivery.
+
+The motivation/inspiration for the transport is to allow external
+processes to access email queued by exim and have access to all the
+information which would not be available if the messages were delivered
+to the process in the standard email formats.
+
+The mailscanner package is one of the processes that can take advantage
+of this transport to filter email.
+
+The transport can be used in the same way as the other existing transports,
+i.e by configuring a router to route mail to a transport configured with
+the queuefile driver.
+
+The transport only takes one option:
+
+* directory - This is used to specify the directory messages should be
+copied to
+
+The generic transport options (body_only, current_directory, disable_logging,
+debug_print, delivery_date_add, envelope_to_add, event_action, group,
+headers_add, headers_only, headers_remove, headers_rewrite, home_directory,
+initgroups, max_parallel, message_size_limit, rcpt_include_affixes,
+retry_use_local_part, return_path, return_path_add, shadow_condition,
+shadow_transport, transport_filter, transport_filter_timeout, user) are
+ignored.
+
+Sample configuration:
+
+(Router)
+
+scan:
+   driver = accept
+   transport = scan
+
+(Transport)
+
+scan:
+  driver = queuefile
+  directory = /var/spool/baruwa-scanner/input
+
+
+In order to build exim with Queuefile transport support add or uncomment
+
+EXPERIMENTAL_QUEUEFILE=yes
+
+to your Local/Makefile. (Re-)build/install exim. exim -d should show
+Experimental_QUEUEFILE in the line "Support for:".
+
+
 --------------------------------------------------------------
 End of file
 --------------------------------------------------------------
 --------------------------------------------------------------
 End of file
 --------------------------------------------------------------
index 86f748c1524023f8aa0404781dd1fe8bc60ea090..b710c2fd8ab6f133fc3888a09a894d41c5c40e7c 100755 (executable)
@@ -59,8 +59,8 @@ cd ..
 mkdir transports
 cd transports
 for f in README Makefile appendfile.h appendfile.c autoreply.h \
 mkdir transports
 cd transports
 for f in README Makefile appendfile.h appendfile.c autoreply.h \
-  autoreply.c lmtp.h lmtp.c pipe.h pipe.c smtp.h smtp.c smtp_socks.c \
-  tf_maildir.c tf_maildir.h
+  autoreply.c lmtp.h lmtp.c pipe.h pipe.c queuefile.c queuefile.h \
+  smtp.h smtp.c smtp_socks.c tf_maildir.c tf_maildir.h
 do
   ln -s ../../src/transports/$f $f
 done
 do
   ln -s ../../src/transports/$f $f
 done
index 10e5ccacb80cab7ba7bb65f3d51fc7ef25bef40a..e2d8cf921f803712fee60ace299c5fdd22c44d61 100644 (file)
@@ -495,6 +495,9 @@ EXIM_MONITOR=eximon.bin
 # CFLAGS += -I/usr/local/include
 # LDFLAGS += -llmdb
 
 # CFLAGS += -I/usr/local/include
 # LDFLAGS += -llmdb
 
+# Uncomment the following line to add queuefile transport support
+# EXPERIMENTAL_QUEUEFILE=yes
+
 ###############################################################################
 #                 THESE ARE THINGS YOU MIGHT WANT TO SPECIFY                  #
 ###############################################################################
 ###############################################################################
 #                 THESE ARE THINGS YOU MIGHT WANT TO SPECIFY                  #
 ###############################################################################
index fe5878aafe9cf27ce19bb3dc6b7ad2527f71a7c5..bafdc1ba43de328d8d2f66ad13d40157d30ab600 100644 (file)
@@ -178,6 +178,7 @@ it's a default value. */
 #define EXPERIMENTAL_DSN_INFO
 #define EXPERIMENTAL_DMARC
 #define EXPERIMENTAL_LMDB
 #define EXPERIMENTAL_DSN_INFO
 #define EXPERIMENTAL_DMARC
 #define EXPERIMENTAL_LMDB
+#define EXPERIMENTAL_QUEUEFILE
 #define EXPERIMENTAL_SPF
 #define EXPERIMENTAL_SRS
 
 #define EXPERIMENTAL_SPF
 #define EXPERIMENTAL_SRS
 
index c807d86c7ebb64b45793fe54615847bbd6537fdd..a3fa328b909d430bd65af8d088337b126abec628 100644 (file)
@@ -228,6 +228,10 @@ exim binary. */
 #include "transports/pipe.h"
 #endif
 
 #include "transports/pipe.h"
 #endif
 
+#ifdef EXPERIMENTAL_QUEUEFILE
+#include "transports/queuefile.h"
+#endif
+
 #ifdef TRANSPORT_SMTP
 #include "transports/smtp.h"
 #endif
 #ifdef TRANSPORT_SMTP
 #include "transports/smtp.h"
 #endif
@@ -389,6 +393,20 @@ transport_info transports_available[] = {
   TRUE                                         /* local flag */
   },
 #endif
   TRUE                                         /* local flag */
   },
 #endif
+#ifdef EXPERIMENTAL_QUEUEFILE
+  {
+  US"queuefile",                               /* driver name */
+  queuefile_transport_options,                 /* local options table */
+  &queuefile_transport_options_count,          /* number of entries */
+  &queuefile_transport_option_defaults,        /* private options defaults */
+  sizeof(queuefile_transport_options_block),   /* size of private block */
+  queuefile_transport_init,                    /* init entry point */
+  queuefile_transport_entry,                   /* main entry point */
+  NULL,                                        /* no tidyup entry */
+  NULL,                                        /* no closedown entry */
+  TRUE                                         /* local flag */
+  },
+#endif
 #ifdef TRANSPORT_SMTP
   {
   US"smtp",                                    /* driver name */
 #ifdef TRANSPORT_SMTP
   {
   US"smtp",                                    /* driver name */
index 905314cadbc2ae267b952b49d69f0a33a108a650..3fdfa62b55a5cb74ec65ad4a1bbc658a903cb340 100644 (file)
@@ -843,6 +843,9 @@ fprintf(f, "Support for:");
 #ifdef EXPERIMENTAL_LMDB
   fprintf(f, " Experimental_LMDB");
 #endif
 #ifdef EXPERIMENTAL_LMDB
   fprintf(f, " Experimental_LMDB");
 #endif
+#ifdef EXPERIMENTAL_QUEUEFILE
+  fprintf(f, " Experimental_QUEUEFILE");
+#endif
 #ifdef EXPERIMENTAL_SPF
   fprintf(f, " Experimental_SPF");
 #endif
 #ifdef EXPERIMENTAL_SPF
   fprintf(f, " Experimental_SPF");
 #endif
@@ -996,6 +999,9 @@ fprintf(f, "Transports:");
 #ifdef TRANSPORT_PIPE
   fprintf(f, " pipe");
 #endif
 #ifdef TRANSPORT_PIPE
   fprintf(f, " pipe");
 #endif
+#ifdef EXPERIMENTAL_QUEUEFILE
+  fprintf(f, " queuefile");
+#endif
 #ifdef TRANSPORT_SMTP
   fprintf(f, " smtp");
 #endif
 #ifdef TRANSPORT_SMTP
   fprintf(f, " smtp");
 #endif
index 03751a8e022cc0db3a1e6dbd13a91659e228ad94..b23c1441be942060c007e368194b159c523d9a48 100644 (file)
@@ -415,6 +415,7 @@ extern int     spam(const uschar **);
 extern FILE   *spool_mbox(unsigned long *, const uschar *);
 #endif
 extern BOOL    spool_move_message(uschar *, uschar *, uschar *, uschar *);
 extern FILE   *spool_mbox(unsigned long *, const uschar *);
 #endif
 extern BOOL    spool_move_message(uschar *, uschar *, uschar *, uschar *);
+extern uschar *spool_dname(const uschar *, uschar *);
 extern uschar *spool_fname(const uschar *, uschar *, uschar *, uschar *);
 extern uschar *spool_sname(const uschar *, uschar *);
 extern int     spool_open_datafile(uschar *);
 extern uschar *spool_fname(const uschar *, uschar *, uschar *, uschar *);
 extern uschar *spool_sname(const uschar *, uschar *);
 extern int     spool_open_datafile(uschar *);
index 969eceba4c251297f80280c86aba4a7aa1aa6fe9..eddb8d85c6a9bd667d89e2e271423a179d5dd331 100644 (file)
@@ -21,7 +21,7 @@ spool_pname_buf(uschar * buf, int len)
 snprintf(CS buf, len, "%s/%s/input", spool_directory, queue_name);
 }
 
 snprintf(CS buf, len, "%s/%s/input", spool_directory, queue_name);
 }
 
-static uschar *
+uschar *
 spool_dname(const uschar * purpose, uschar * subdir)
 {
 return string_sprintf("%s/%s/%s/%s",
 spool_dname(const uschar * purpose, uschar * subdir)
 {
 return string_sprintf("%s/%s/%s/%s",
index 25973d5df1913cad024973609a123159a92d8568..4eea141ec9481a6d8d21adbacb7e8d3dcc19c326 100644 (file)
@@ -2,7 +2,7 @@
 # calling it transports.a. This is called from the main make file, after cd'ing
 # to the transports subdirectory.
 
 # calling it transports.a. This is called from the main make file, after cd'ing
 # to the transports subdirectory.
 
-OBJ = appendfile.o autoreply.o lmtp.o pipe.o smtp.o smtp_socks.o tf_maildir.o
+OBJ = appendfile.o autoreply.o lmtp.o pipe.o queuefile.o smtp.o smtp_socks.o tf_maildir.o
 
 transports.a:    $(OBJ)
                 @$(RM_COMMAND) -f transports.a
 
 transports.a:    $(OBJ)
                 @$(RM_COMMAND) -f transports.a
@@ -18,6 +18,7 @@ appendfile.o:    $(HDRS) appendfile.c appendfile.h tf_maildir.h
 autoreply.o:     $(HDRS) autoreply.c autoreply.h
 lmtp.o:          $(HDRS) lmtp.c lmtp.h
 pipe.o:          $(HDRS) pipe.c pipe.h
 autoreply.o:     $(HDRS) autoreply.c autoreply.h
 lmtp.o:          $(HDRS) lmtp.c lmtp.h
 pipe.o:          $(HDRS) pipe.c pipe.h
+queuefile.o:     $(HDRS) queuefile.c queuefile.h
 smtp.o:          $(HDRS) smtp.c smtp.h
 smtp_socks.o:    $(HDRS) smtp_socks.c smtp.h
 
 smtp.o:          $(HDRS) smtp.c smtp.h
 smtp_socks.o:    $(HDRS) smtp_socks.c smtp.h
 
diff --git a/src/src/transports/queuefile.c b/src/src/transports/queuefile.c
new file mode 100644 (file)
index 0000000..3f711c1
--- /dev/null
@@ -0,0 +1,339 @@
+/*************************************************
+*     Exim - an Internet mail transport agent    *
+*************************************************/
+
+/* Copyright (c) Andrew Colin Kissa <andrew@topdog.za.net> 2016 */
+/* Copyright (c) University of Cambridge 2016 */
+/* See the file NOTICE for conditions of use and distribution. */
+
+
+#include "../exim.h"
+#include "queuefile.h"
+
+/* Options specific to the appendfile transport. They must be in alphabetic
+order (note that "_" comes before the lower case letters). Some of them are
+stored in the publicly visible instance block - these are flagged with the
+opt_public flag. */
+
+optionlist queuefile_transport_options[] = {
+  { "directory", opt_stringptr,
+    (void *)offsetof(queuefile_transport_options_block, dirname) },
+};
+
+/* Size of the options list. An extern variable has to be used so that its
+address can appear in the tables drtables.c. */
+
+int queuefile_transport_options_count =
+  sizeof(queuefile_transport_options) / sizeof(optionlist);
+
+/* Default private options block for the appendfile transport. */
+
+queuefile_transport_options_block queuefile_transport_option_defaults = {
+  NULL,           /* dirname */
+};
+
+/*************************************************
+*          Initialization entry point            *
+*************************************************/
+
+void queuefile_transport_init(transport_instance *tblock)
+{
+queuefile_transport_options_block *ob =
+  (queuefile_transport_options_block *)(tblock->options_block);
+
+if (ob->dirname == NULL)
+  log_write(0, LOG_PANIC_DIE | LOG_CONFIG,
+    "directory must be set for the %s transport", tblock->name);
+}
+
+/* This function will copy from a file to another
+
+Arguments:
+  to_fd        FILE to write to (the destination queue file)
+  from_fd      FILE to read from (the spool queue file)
+
+Returns:       TRUE if all went well, FALSE otherwise
+*/
+
+static BOOL copy_spool_file (FILE *to_fd, FILE *from_fd)
+{
+int i, j;
+uschar buffer[16384];
+
+rewind(from_fd);
+
+do
+  {
+    j = fread(buffer, 1, sizeof(buffer), from_fd);
+    if (j > 0)
+      {
+      i = fwrite(buffer, j, 1, to_fd);
+      if (i != 1)
+        return FALSE;
+      }
+  }
+while (j > 0);
+return TRUE;
+}
+
+/* This function performs the actual copying of the header
+and data files to the destination directory
+
+Arguments:
+  tname         uschar the transport name
+  addr          address_item being processed
+  sdfd          int Source directory fd
+  ddfd          int Destination directory fd
+  suffix        uschar file suffix
+  dirname       uschar Destination directory
+  link_file     BOOL use linkat instead of data copy
+  is_data_file  BOOL the file is a data file not a header file
+  dst_file      FILE to write to
+  src_file      FILE to read from
+
+Returns:       TRUE if all went well, FALSE otherwise
+*/
+
+static BOOL copy_spool_files(uschar *tname, address_item *addr,
+  int sdfd, int ddfd, uschar *suffix, uschar *dirname, BOOL link_file,
+  BOOL is_data_file, FILE *dst_file, FILE *src_file)
+{
+int dstfd, srcfd;
+/*
+uschar message_subdir[2];
+message_subdir[1] = '\0';
+message_subdir[0] = split_spool_directory? message_id[5] : 0;
+*/
+uschar *filename = string_sprintf("%s-%s", message_id, suffix);
+/*
+uschar *srcpath = string_sprintf("%s/%s/%s/%s-%s", spool_directory,
+    US"input", message_subdir, message_id, suffix);
+*/
+uschar *srcpath = spool_fname(US"input", message_subdir, message_id, suffix);
+uschar *dstpath = string_sprintf("%s/%s-%s", dirname, message_id, suffix);
+
+if (link_file)
+  {
+  /* use linkat */
+  DEBUG(D_transport)
+    debug_printf("%s transport, linking %s => %s\n", tname,
+      srcpath, dstpath);
+  if (linkat(sdfd, CCS filename, ddfd, CCS filename, 0) < 0)
+    return FALSE;
+  return TRUE;
+  }
+else
+  {
+  /* use data copy */
+  DEBUG(D_transport)
+    debug_printf("%s transport, copying %s => %s\n", tname,
+      srcpath, dstpath);
+  if ((dstfd =
+    openat(ddfd, CCS filename, O_RDWR|O_CREAT|O_EXCL, SPOOL_MODE)) < 0)
+    {
+    addr->transport_return = DEFER;
+    addr->basic_errno = errno;
+    addr->message = string_sprintf("%s transport opening file: %s "
+      "failed with error: %s", tname, dstpath, strerror(errno));
+    return FALSE;
+    }
+
+  fchmod(dstfd, SPOOL_MODE);
+
+  if ((dst_file = fdopen(dstfd, "wb")) < 0)
+    {
+    addr->transport_return = DEFER;
+    addr->basic_errno = errno;
+    addr->message = string_sprintf("%s transport opening file fd: %s "
+      "failed with error: %s", tname, dstpath, strerror(errno));
+    (void)close(dstfd);
+    return FALSE;
+    }
+
+  if (is_data_file)
+    srcfd = deliver_datafile;
+  else
+    {
+    if ((srcfd = openat(sdfd, CCS filename, O_RDONLY)) < 0)
+      {
+      addr->transport_return = DEFER;
+      addr->basic_errno = errno;
+      addr->message = string_sprintf("%s transport opening file: %s "
+        "failed with error: %s", tname, srcpath, strerror(errno));
+      return FALSE;
+      }
+    }
+
+  if ((src_file = fdopen(srcfd, "rb")) < 0)
+    {
+    addr->transport_return = DEFER;
+    addr->basic_errno = errno;
+    addr->message = string_sprintf("%s transport opening file fd: "
+      "%s failed with error: %s", tname, srcpath, strerror(errno));
+    if (!is_data_file) (void)close(srcfd);
+    return FALSE;
+    }
+
+  if (!copy_spool_file(dst_file, src_file))
+    {
+    addr->transport_return = DEFER;
+    addr->message = string_sprintf("%s transport creating file: "
+      "%s failed with error: %s", tname, dstpath, strerror(errno));
+    return FALSE;
+    }
+
+  if (!is_data_file)
+    {
+    (void)fclose(src_file);
+    src_file = NULL;
+    }
+
+  (void)fclose(dst_file);
+  dst_file = NULL;
+
+  } /* end data copy */
+
+return TRUE;
+}
+
+/*************************************************
+*              Main entry point                  *
+*************************************************/
+
+/* This transport always returns FALSE, indicating that the status in
+the first address is the status for all addresses in a batch. */
+
+BOOL queuefile_transport_entry(transport_instance *tblock,
+  address_item *addr)
+{
+BOOL link_file;
+BOOL is_data_file;
+uschar *sourcedir;
+struct stat dstatbuf;
+struct stat sstatbuf;
+FILE *dst_file = NULL;
+FILE *src_file = NULL;
+/* uschar message_subdir[2]; */
+int ddfd, sdfd, dfd_oflags;
+queuefile_transport_options_block *ob =
+  (queuefile_transport_options_block *)(tblock->options_block);
+
+DEBUG(D_transport)
+  debug_printf("%s transport entered\n", tblock->name);
+
+# ifndef O_DIRECTORY
+#  define O_DIRECTORY 0
+# endif
+
+dfd_oflags = O_RDONLY|O_DIRECTORY;
+#ifdef O_NOFOLLOW
+dfd_oflags |= O_NOFOLLOW;
+#endif
+
+if (ob->dirname[0] != '/')
+  {
+  addr->transport_return = PANIC;
+  addr->message = string_sprintf("%s transport directory: "
+    "%s is not absolute", tblock->name, ob->dirname);
+  return FALSE;
+  }
+
+if ((ddfd = Uopen(ob->dirname, dfd_oflags, 0)) < 0)
+  {
+  addr->transport_return = PANIC;
+  addr->basic_errno = errno;
+  addr->message = string_sprintf("%s transport accessing directory: %s "
+    "failed with error: %s", tblock->name, ob->dirname, strerror(errno));
+  return FALSE;
+  }
+
+
+if ((fstat(ddfd, &dstatbuf)) < 0)
+  {
+  addr->transport_return = PANIC;
+  addr->basic_errno = errno;
+  addr->message = string_sprintf("%s transport fstat on directory fd: "
+    "%s failed with error: %s", tblock->name, ob->dirname, strerror(errno));
+  goto RETURN;
+  }
+
+sourcedir = spool_dname(US"input", message_subdir);
+/*
+message_subdir[1] = '\0';
+message_subdir[0] = split_spool_directory? message_id[5] : 0;
+sourcedir = string_sprintf("%s/%s/%s", spool_directory,
+  US"input", message_subdir);
+*/
+
+if ((sdfd = Uopen(sourcedir, dfd_oflags, 0)) < 0)
+  {
+  addr->transport_return = PANIC;
+  addr->basic_errno = errno;
+  addr->message = string_sprintf("%s transport accessing directory: %s "
+    "failed with error: %s", tblock->name, sourcedir, strerror(errno));
+  goto RETURN;
+  }
+
+if ((fstat(sdfd, &sstatbuf)) < 0)
+  {
+  addr->transport_return = PANIC;
+  addr->basic_errno = errno;
+  addr->message = string_sprintf("%s transport fstat on directory fd: "
+    "%s failed with error: %s", tblock->name, sourcedir, strerror(errno));
+  goto RETURN;
+  }
+
+if (dont_deliver)
+  {
+  DEBUG(D_transport)
+    debug_printf("*** delivery by %s transport bypassed by -N option\n",
+      tblock->name);
+  addr->transport_return = OK;
+  goto RETURN;
+  }
+
+/* process the header file */
+DEBUG(D_transport)
+  debug_printf("%s transport, copying header file\n", tblock->name);
+
+is_data_file = FALSE;
+link_file = (dstatbuf.st_dev == sstatbuf.st_dev);
+
+if ((copy_spool_files(tblock->name, addr, sdfd, ddfd, US"H", ob->dirname,
+  link_file, is_data_file, dst_file, src_file)) == FALSE)
+  goto RETURN;
+
+/* process the data file */
+DEBUG(D_transport)
+  debug_printf("%s transport, copying data file\n", tblock->name);
+
+is_data_file = TRUE;
+
+if ((copy_spool_files(tblock->name, addr, sdfd, ddfd, US"D", ob->dirname,
+  link_file, is_data_file, dst_file, src_file)) == FALSE)
+  {
+  DEBUG(D_transport)
+    debug_printf("%s transport, copying data file failed, "
+      "unlinking the header file\n", tblock->name);
+  Uunlink(string_sprintf("%s/%s-H", ob->dirname, message_id));
+  goto RETURN;
+  }
+
+(void)close(ddfd);
+(void)close(sdfd);
+
+DEBUG(D_transport)
+  debug_printf("%s transport succeeded\n", tblock->name);
+
+addr->transport_return = OK;
+
+RETURN:
+if (dst_file) (void)fclose(dst_file);
+if (src_file && !is_data_file) (void)fclose(src_file);
+if (ddfd) (void)close(ddfd);
+if (sdfd) (void)close(sdfd);
+
+/* A return of FALSE means that if there was an error, a common error was
+put in the first address of a batch. */
+return FALSE;
+}
diff --git a/src/src/transports/queuefile.h b/src/src/transports/queuefile.h
new file mode 100644 (file)
index 0000000..0e45b51
--- /dev/null
@@ -0,0 +1,29 @@
+/*************************************************
+*     Exim - an Internet mail transport agent    *
+*************************************************/
+
+/* Copyright (c) Andrew Colin Kissa <andrew@topdog.za.net> 2016 */
+/* Copyright (c) University of Cambridge 2016 */
+/* See the file NOTICE for conditions of use and distribution. */
+
+/* Private structure for the private options. */
+
+typedef struct {
+    uschar *dirname;
+} queuefile_transport_options_block;
+
+/* Data for reading the private options. */
+
+extern optionlist queuefile_transport_options[];
+extern int queuefile_transport_options_count;
+
+/* Block containing default values. */
+
+extern queuefile_transport_options_block queuefile_transport_option_defaults;
+
+/* The main and init entry points for the transport */
+
+extern BOOL queuefile_transport_entry(transport_instance *, address_item *);
+extern void queuefile_transport_init(transport_instance *);
+
+/* End of transports/queuefile.h */
diff --git a/test/confs/5900 b/test/confs/5900
new file mode 100644 (file)
index 0000000..f5766d4
--- /dev/null
@@ -0,0 +1,35 @@
+# Exim test configuration 5900
+
+.include DIR/aux-var/std_conf_prefix
+
+
+# ----- Main settings -----
+
+qualify_domain = test.ex
+
+
+# ----- Routers -----
+
+begin routers
+
+scan:
+   driver = accept
+   transport = scan
+
+
+# ----- Transports -----
+
+begin transports
+
+scan:
+  driver = queuefile
+  directory = DIR/test-mail/subdir
+
+# ----- Retry -----
+
+begin retry
+
+* * F,10m,2d
+
+
+# End
diff --git a/test/confs/5901 b/test/confs/5901
new file mode 100644 (file)
index 0000000..5d57c1c
--- /dev/null
@@ -0,0 +1,35 @@
+# Exim test configuration 5901
+
+.include DIR/aux-var/std_conf_prefix
+
+
+# ----- Main settings -----
+
+qualify_domain = test.ex
+
+
+# ----- Routers -----
+
+begin routers
+
+scan:
+   driver = accept
+   transport = scan
+
+
+# ----- Transports -----
+
+begin transports
+
+scan:
+  driver = queuefile
+  directory = test-mail/subdir
+
+# ----- Retry -----
+
+begin retry
+
+* * F,10m,2d
+
+
+# End
diff --git a/test/confs/5902 b/test/confs/5902
new file mode 100644 (file)
index 0000000..e7dad63
--- /dev/null
@@ -0,0 +1,54 @@
+# Exim test configuration 5902
+
+.include DIR/aux-var/std_conf_prefix
+
+
+# ----- Main settings -----
+
+qualify_domain = test.ex
+acl_smtp_rcpt = rcpt
+
+# ----- ACLs -----
+
+begin acl
+
+rcpt:
+ accept
+ queue = ${if eq {normal}{$local_part} {} {$local_part}}
+ logwrite = using queue '$queue_name'
+
+# ----- Routers -----
+
+begin routers
+
+local:
+   driver = accept
+   transport = local_delivery
+   condition = ${if eq {}{$queue_name} {1}{0}}
+
+scan:
+   driver = accept
+   transport = scan
+
+
+# ----- Transports -----
+
+begin transports
+
+scan:
+  driver = queuefile
+  directory = DIR/aux-fixed/5902/outbound
+
+local_delivery:
+  driver = appendfile
+  file = DIR/test-mail/$local_part
+  user = CALLER
+
+# ----- Retry -----
+
+begin retry
+
+* * F,10m,2d
+
+
+# End
diff --git a/test/log/5900 b/test/log/5900
new file mode 100644 (file)
index 0000000..8b273b8
--- /dev/null
@@ -0,0 +1,2 @@
+1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@test.ex U=CALLER P=local S=sss
+1999-03-02 09:44:33 10HmaX-0005vi-00 == userx@test.ex R=scan T=scan defer (2): No such file or directory: scan transport accessing directory: TESTSUITE/test-mail/subdir failed with error: No such file or directory
diff --git a/test/log/5901 b/test/log/5901
new file mode 100644 (file)
index 0000000..6a3797a
--- /dev/null
@@ -0,0 +1,2 @@
+1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@test.ex U=CALLER P=local S=sss
+1999-03-02 09:44:33 10HmaX-0005vi-00 == userx@test.ex R=scan T=scan defer (-1): scan transport directory: test-mail/subdir is not absolute
diff --git a/test/log/5902 b/test/log/5902
new file mode 100644 (file)
index 0000000..6b45d9b
--- /dev/null
@@ -0,0 +1,11 @@
+1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@test.ex U=CALLER P=local S=sss
+1999-03-02 09:44:33 10HmaX-0005vi-00 => normal <normal@test.ex> R=local T=local_delivery
+1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
+1999-03-02 09:44:33 using queue 'user1'
+1999-03-02 09:44:33 10HmaY-0005vi-00 <= CALLER@test.ex U=CALLER P=local-smtp S=sss Q=user1
+1999-03-02 09:44:33 10HmaY-0005vi-00 => user1 <user1@test.ex> Q=user1 R=scan T=scan
+1999-03-02 09:44:33 10HmaY-0005vi-00 Completed
+1999-03-02 09:44:33 Start queue run: pid=pppp
+1999-03-02 09:44:33 10HmaY-0005vi-00 => user1 <user1@test.ex> R=local T=local_delivery
+1999-03-02 09:44:33 10HmaY-0005vi-00 Completed
+1999-03-02 09:44:33 End queue run: pid=pppp
diff --git a/test/mail/5902.user1.5902 b/test/mail/5902.user1.5902
new file mode 100644 (file)
index 0000000..3b6bde5
--- /dev/null
@@ -0,0 +1,12 @@
+From CALLER@test.ex Tue Mar 02 09:44:33 1999
+Received: from CALLER by the.local.host.name with local-smtp (Exim x.yz)
+       (envelope-from <CALLER@test.ex>)
+       id 10HmaY-0005vi-00
+       for user1@test.ex; Tue, 2 Mar 1999 09:44:33 +0000
+Subject: test
+Message-Id: <E10HmaY-0005vi-00@the.local.host.name>
+From: CALLER_NAME <CALLER@test.ex>
+Date: Tue, 2 Mar 1999 09:44:33 +0000
+
+foo
+
diff --git a/test/paniclog/5900 b/test/paniclog/5900
new file mode 100644 (file)
index 0000000..70058d7
--- /dev/null
@@ -0,0 +1 @@
+1999-03-02 09:44:33 10HmaX-0005vi-00 == userx@test.ex R=scan T=scan defer (2): No such file or directory: scan transport accessing directory: TESTSUITE/test-mail/subdir failed with error: No such file or directory
diff --git a/test/paniclog/5901 b/test/paniclog/5901
new file mode 100644 (file)
index 0000000..111bae4
--- /dev/null
@@ -0,0 +1 @@
+1999-03-02 09:44:33 10HmaX-0005vi-00 == userx@test.ex R=scan T=scan defer (-1): scan transport directory: test-mail/subdir is not absolute
diff --git a/test/scripts/5900-queuefile-transport/5900 b/test/scripts/5900-queuefile-transport/5900
new file mode 100644 (file)
index 0000000..3d90554
--- /dev/null
@@ -0,0 +1,4 @@
+# queuefile transport test non existant directory
+exim -odi userx
+****
+no_msglog_check
diff --git a/test/scripts/5900-queuefile-transport/5901 b/test/scripts/5900-queuefile-transport/5901
new file mode 100644 (file)
index 0000000..b0f74f0
--- /dev/null
@@ -0,0 +1,4 @@
+# queuefile transport test relative directory
+exim -odi userx
+****
+no_msglog_check
diff --git a/test/scripts/5900-queuefile-transport/5902 b/test/scripts/5900-queuefile-transport/5902
new file mode 100644 (file)
index 0000000..4b2a9a6
--- /dev/null
@@ -0,0 +1,22 @@
+# queuefile transport test delivery
+sudo chown EXIMUSER:EXIMGROUP DIR/aux-fixed/5902/outbound
+exim -odi normal
+****
+sleep 5
+#
+exim -bs
+MAIL FROM:<CALLER@myhost.test.ex>
+RCPT TO: <user1@test.ex>
+DATA
+Subject: test
+
+foo
+.
+QUIT
+****
+sleep 5
+# 
+ls DIR/aux-fixed/5902/outbound
+sudo mv DIR/aux-fixed/5902/outbound/1* DIR/spool/input/
+exim -q
+no_msglog_check
diff --git a/test/scripts/5900-queuefile-transport/REQUIRES b/test/scripts/5900-queuefile-transport/REQUIRES
new file mode 100644 (file)
index 0000000..f24c3ba
--- /dev/null
@@ -0,0 +1 @@
+support Experimental_QUEUEFILE
diff --git a/test/stderr/5900 b/test/stderr/5900
new file mode 100644 (file)
index 0000000..70058d7
--- /dev/null
@@ -0,0 +1 @@
+1999-03-02 09:44:33 10HmaX-0005vi-00 == userx@test.ex R=scan T=scan defer (2): No such file or directory: scan transport accessing directory: TESTSUITE/test-mail/subdir failed with error: No such file or directory
diff --git a/test/stderr/5901 b/test/stderr/5901
new file mode 100644 (file)
index 0000000..111bae4
--- /dev/null
@@ -0,0 +1 @@
+1999-03-02 09:44:33 10HmaX-0005vi-00 == userx@test.ex R=scan T=scan defer (-1): scan transport directory: test-mail/subdir is not absolute
diff --git a/test/stdout/5902 b/test/stdout/5902
new file mode 100644 (file)
index 0000000..a16696f
--- /dev/null
@@ -0,0 +1,8 @@
+220 the.local.host.name ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
+250 OK\r
+250 Accepted\r
+354 Enter message, ending with "." on a line by itself\r
+250 OK id=10HmaY-0005vi-00\r
+221 the.local.host.name closing connection\r
+10HmaY-0005vi-00-D
+10HmaY-0005vi-00-H