summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2015-01-13 10:59:07 +0000
committerJeremy Harris <jgh146exb@wizmail.org>2015-01-13 11:01:27 +0000
commit0ad2e0fcde2f23e3809687095bddb31f9af4896e (patch)
tree096e6a02ef09f005789bd5011502a02ec12c0691
parent31f5ec432e49826b039e3b527e9c65d4dfa18b60 (diff)
Add cmdline option to append a log message. Bug 418
-rw-r--r--doc/doc-docbook/spec.xfpt7
-rw-r--r--src/src/exim.c23
-rw-r--r--test/confs/060213
-rw-r--r--test/log/06021
-rw-r--r--test/scripts/0000-Basic/06025
5 files changed, 47 insertions, 2 deletions
diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt
index f4263bff6..a102ad790 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 00c5974d2..e0c591d63 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 000000000..048175d5e
--- /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 000000000..ffa899166
--- /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 000000000..3afdf5e3d
--- /dev/null
+++ b/test/scripts/0000-Basic/0602
@@ -0,0 +1,5 @@
+# log line write
+#
+#
+exim -z "This argument written, with newline, to log"
+***