[exim-cvs] Add cmdline option to append a log message. Bug …

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Exim Git Commits Mailing List
Datum:  
To: exim-cvs
Betreff: [exim-cvs] Add cmdline option to append a log message. Bug 418
Gitweb: http://git.exim.org/exim.git/commitdiff/0ad2e0fcde2f23e3809687095bddb31f9af4896e
Commit:     0ad2e0fcde2f23e3809687095bddb31f9af4896e
Parent:     31f5ec432e49826b039e3b527e9c65d4dfa18b60
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Tue Jan 13 10:59:07 2015 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Tue Jan 13 11:01:27 2015 +0000


    Add cmdline option to append a log message.  Bug 418
---
 doc/doc-docbook/spec.xfpt    |    7 +++++++
 src/src/exim.c               |   23 +++++++++++++++++++++--
 test/confs/0602              |   13 +++++++++++++
 test/log/0602                |    1 +
 test/scripts/0000-Basic/0602 |    5 +++++
 5 files changed, 47 insertions(+), 2 deletions(-)


diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt
index f4263bf..a102ad7 100644
--- a/doc/doc-docbook/spec.xfpt
+++ b/doc/doc-docbook/spec.xfpt
@@ -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
diff --git a/src/src/exim.c b/src/src/exim.c
index 00c5974..e0c591d 100644
--- a/src/src/exim.c
+++ b/src/src/exim.c
@@ -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
index 0000000..048175d
--- /dev/null
+++ b/test/confs/0602
@@ -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
index 0000000..ffa8991
--- /dev/null
+++ b/test/log/0602
@@ -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
index 0000000..3afdf5e
--- /dev/null
+++ b/test/scripts/0000-Basic/0602
@@ -0,0 +1,5 @@
+# log line write
+#
+#
+exim -z "This argument written, with newline, to log"
+***