Add cmdline option to append a log message. Bug 418
authorJeremy Harris <jgh146exb@wizmail.org>
Tue, 13 Jan 2015 10:59:07 +0000 (10:59 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Tue, 13 Jan 2015 11:01:27 +0000 (11:01 +0000)
doc/doc-docbook/spec.xfpt
src/src/exim.c
test/confs/0602 [new file with mode: 0644]
test/log/0602 [new file with mode: 0644]
test/scripts/0000-Basic/0602 [new file with mode: 0644]

index f4263bff6a72ef9fc044bf89f779e50f8ab3c559..a102ad7909bb806c6801bfcb842fce17cdca6ffc 100644 (file)
@@ -4648,6 +4648,13 @@ this option.
 .oindex "&%-X%&"
 This option is interpreted by Sendmail to cause debug information to be sent
 to the named file.  It is ignored by Exim.
+
+.vitem &%-z%&&~<&'log-line'&>
+.oindex "&%-z%&"
+This option writes its argument to Exim's logfile.
+Use is restricted to administrators; the intent is for operational notes.
+Quotes should be used to maintain a multi-word item as a single argument,
+under most shells.
 .endlist
 
 .ecindex IIDclo1
index 00c5974d255cc10c97dbc93cc850ee9aca444235..e0c591d63882de5ab132c762b6a1176f1db91de6 100644 (file)
@@ -1501,6 +1501,7 @@ uschar *ftest_domain = NULL;
 uschar *ftest_localpart = NULL;
 uschar *ftest_prefix = NULL;
 uschar *ftest_suffix = NULL;
+uschar *log_oneline = NULL;
 uschar *malware_test_file = NULL;
 uschar *real_sender_address;
 uschar *originator_home = US"/";
@@ -3384,13 +3385,20 @@ for (i = 1; i < argc; i++)
 
     case 'X':
     if (*argrest == '\0')
-      {
       if (++i >= argc)
         {
         fprintf(stderr, "exim: string expected after -X\n");
         exit(EXIT_FAILURE);
         }
-      }
+    break;
+
+    case 'z':
+    if (*argrest == '\0')
+      if (++i < argc) log_oneline = argv[i]; else
+        {
+        fprintf(stderr, "exim: file name expected after %s\n", argv[i-1]);
+        exit(EXIT_FAILURE);
+        }
     break;
 
     /* All other initial characters are errors */
@@ -3833,6 +3841,17 @@ if (Ustrlen(syslog_processname) > 32)
   log_write(0, LOG_MAIN|LOG_PANIC_DIE,
     "syslog_processname is longer than 32 chars: aborting");
 
+if (log_oneline)
+  {
+  if (admin_user)
+    {
+    log_write(0, LOG_MAIN, "%s", log_oneline);
+    return EXIT_SUCCESS;
+    }
+  else
+    return EXIT_FAILURE;
+  }
+
 /* In some operating systems, the environment variable TMPDIR controls where
 temporary files are created; Exim doesn't use these (apart from when delivering
 to MBX mailboxes), but called libraries such as DBM libraries may require them.
diff --git a/test/confs/0602 b/test/confs/0602
new file mode 100644 (file)
index 0000000..048175d
--- /dev/null
@@ -0,0 +1,13 @@
+# Exim test configuration 0602
+
+exim_path = EXIM_PATH
+spool_directory = DIR/spool
+log_file_path = DIR/spool/log/%slog
+gecos_pattern = ""
+gecos_name = CALLER_NAME
+
+# ----- Main settings -----
+
+acl_smtp_rcpt = reject
+
+# End
diff --git a/test/log/0602 b/test/log/0602
new file mode 100644 (file)
index 0000000..ffa8991
--- /dev/null
@@ -0,0 +1 @@
+1999-03-02 09:44:33 This argument written, with newline, to log
diff --git a/test/scripts/0000-Basic/0602 b/test/scripts/0000-Basic/0602
new file mode 100644 (file)
index 0000000..3afdf5e
--- /dev/null
@@ -0,0 +1,5 @@
+# log line write
+#
+#
+exim -z "This argument written, with newline, to log"
+***