summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Pennock <pdp@exim.org>2012-06-01 03:37:26 -0400
committerPhil Pennock <pdp@exim.org>2012-06-01 03:37:26 -0400
commit98a90c36edb0fbe03e6db6bf4ad4fff0892f18bb (patch)
treee23ff690d3f95f4ba3eccb66b9d436e5a3ba6c79
parent2341d632dfbd25fae2fe13dd7585f812dd8277a8 (diff)
Add -bI:help and -bI:sieve
-rw-r--r--doc/doc-docbook/spec.xfpt19
-rw-r--r--doc/doc-txt/ChangeLog6
-rw-r--r--doc/doc-txt/NewStuff10
-rw-r--r--src/src/exim.c74
-rw-r--r--src/src/globals.h1
-rw-r--r--src/src/sieve.c32
6 files changed, 141 insertions, 1 deletions
diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt
index 7b8c17b44..9637b5194 100644
--- a/doc/doc-docbook/spec.xfpt
+++ b/doc/doc-docbook/spec.xfpt
@@ -2937,6 +2937,25 @@ use the &'exim_dbmbuild'& utility, or some other means, to rebuild alias files
if this is required. If the &%bi_command%& option is not set, calling Exim with
&%-bi%& is a no-op.
+.vitem &%-bI:help%&
+.oindex "&%-bI:help%&"
+.cindex "querying exim information"
+We shall provide various options starting &`-bI:`& for querying Exim for
+information. The output of many of these will be intended for machine
+consumption. This one is not. The &%-bI:help%& option asks Exim for a
+synopsis of supported options beginning &`-bI:`&. Use of any of these
+options shall cause Exim to exit after producing the requested output.
+
+.vitem &%-bI:sieve%&
+.oindex "&%-bI:sieve%&"
+.cindex "Sieve filter" "capabilities"
+This option causes Exim to emit an alphabetically sorted list of all supported
+Sieve protocol extensions on stdout, one per line. This is anticipated to be
+useful for ManageSieve (RFC 5804) implementations, in providing that protocol's
+&`SIEVE`& capability response line. As the precise list may depend upon
+compile-time build options, which this option will adapt to, this is the only
+way to guarantee a correct response.
+
.vitem &%-bm%&
.oindex "&%-bm%&"
.cindex "local message reception"
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 6c0554b5a..d79f4eefe 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -1,6 +1,12 @@
Change log file for Exim from version 4.21
-------------------------------------------
+Exim version 4.81
+-----------------
+
+PP/01 Add -bI: framework, and -bI:sieve for querying sieve capabilities.
+
+
Exim version 4.80
-----------------
diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff
index 4b9142238..71f1e8ee3 100644
--- a/doc/doc-txt/NewStuff
+++ b/doc/doc-txt/NewStuff
@@ -6,6 +6,16 @@ Before a formal release, there may be quite a lot of detail so that people can
test from the snapshots or the CVS before the documentation is updated. Once
the documentation is updated, this file is reduced to a short list.
+Version 4.81
+------------
+
+ 1. New command-line option -bI:sieve will list all supported sieve extensions
+ of this Exim build on standard output, one per line.
+ ManageSieve (RFC 5804) providers managing scripts for use by Exim should
+ query this to establish the correct list to include in the protocol's
+ SIEVE capability line.
+
+
Version 4.80
------------
diff --git a/src/src/exim.c b/src/src/exim.c
index 76355afcc..ff6b4dd86 100644
--- a/src/src/exim.c
+++ b/src/src/exim.c
@@ -53,6 +53,16 @@ store_free(block);
/*************************************************
+* Enums for cmdline interface *
+*************************************************/
+
+enum commandline_info { CMDINFO_NONE=0,
+ CMDINFO_HELP, CMDINFO_SIEVE };
+
+
+
+
+/*************************************************
* Compile regular expression and panic on fail *
*************************************************/
@@ -1014,6 +1024,36 @@ DEBUG(D_any) do {
}
+/*************************************************
+* Show auxiliary information about Exim *
+*************************************************/
+
+static void
+show_exim_information(enum commandline_info request, FILE *stream)
+{
+const uschar **pp;
+
+switch(request)
+ {
+ case CMDINFO_NONE:
+ fprintf(stream, "Oops, something went wrong.\n");
+ return;
+ case CMDINFO_HELP:
+ fprintf(stream,
+"The -bI: flag takes a string indicating which information to provide.\n"
+"If the string is not recognised, you'll get this help (on stderr).\n"
+"\n"
+" exim -bI:help this information\n"
+" exim -bI:sieve list of supported sieve extensions, one per line.\n"
+);
+ return;
+ case CMDINFO_SIEVE:
+ for (pp = exim_sieve_extension_list; *pp; ++pp)
+ fprintf(stream, "%s\n", *pp);
+ return;
+
+ }
+}
/*************************************************
@@ -1429,6 +1469,10 @@ pid_t passed_qr_pid = (pid_t)0;
int passed_qr_pipe = -1;
gid_t group_list[NGROUPS_MAX];
+/* For the -bI: flag */
+enum commandline_info info_flag = CMDINFO_NONE;
+BOOL info_stdout = FALSE;
+
/* Possible options for -R and -S */
static uschar *rsopts[] = { US"f", US"ff", US"r", US"rf", US"rff" };
@@ -1928,6 +1972,27 @@ for (i = 1; i < argc; i++)
else if (Ustrcmp(argrest, "i") == 0) bi_option = TRUE;
+ /* -bI: provide information, of the type to follow after a colon.
+ This is an Exim flag. */
+
+ else if (argrest[0] == 'I' && Ustrlen(argrest) >= 2 && argrest[1] == ':')
+ {
+ uschar *p = &argrest[2];
+ info_flag = CMDINFO_HELP;
+ if (Ustrlen(p))
+ {
+ if (strcmpic(p, CUS"sieve") == 0)
+ {
+ info_flag = CMDINFO_SIEVE;
+ info_stdout = TRUE;
+ }
+ else if (strcmpic(p, CUS"help") == 0)
+ {
+ info_stdout = TRUE;
+ }
+ }
+ }
+
/* -bm: Accept and deliver message - the default option. Reinstate
receiving_message, which got turned off for all -b options. */
@@ -4766,7 +4831,8 @@ if (host_checking)
/* Arrange for message reception if recipients or SMTP were specified;
otherwise complain unless a version print (-bV) happened or this is a filter
-verification test. In the former case, show the configuration file name. */
+verification test or info dump.
+In the former case, show the configuration file name. */
if (recipients_arg >= argc && !extract_recipients && !smtp_input)
{
@@ -4776,6 +4842,12 @@ if (recipients_arg >= argc && !extract_recipients && !smtp_input)
return EXIT_SUCCESS;
}
+ if (info_flag != CMDINFO_NONE)
+ {
+ show_exim_information(info_flag, info_stdout ? stdout : stderr);
+ return info_stdout ? EXIT_SUCCESS : EXIT_FAILURE;
+ }
+
if (filter_test == FTEST_NONE)
exim_usage(called_as);
}
diff --git a/src/src/globals.h b/src/src/globals.h
index fbbec3230..b1ec5a20f 100644
--- a/src/src/globals.h
+++ b/src/src/globals.h
@@ -360,6 +360,7 @@ extern int errors_sender_rc; /* Return after message to sender*/
extern gid_t exim_gid; /* To be used with exim_uid */
extern BOOL exim_gid_set; /* TRUE if exim_gid set */
extern uschar *exim_path; /* Path to exec exim */
+extern const uschar *exim_sieve_extension_list[]; /* list of sieve extensions */
extern uid_t exim_uid; /* Non-root uid for exim */
extern BOOL exim_uid_set; /* TRUE if exim_uid set */
extern int expand_forbid; /* RDO flags for forbidding things */
diff --git a/src/src/sieve.c b/src/src/sieve.c
index e5088eb45..305ff3bf3 100644
--- a/src/src/sieve.c
+++ b/src/src/sieve.c
@@ -107,6 +107,38 @@ struct Notification
struct Notification *next;
};
+/* This should be a complete list of supported extensions, so that an external
+ManageSieve (RFC 5804) program can interrogate the current Exim binary for the
+list of extensions and provide correct information to a client.
+
+We'll emit the list in the order given here; keep it alphabetically sorted, so
+that callers don't get surprised.
+
+List *MUST* end with a NULL. Which at least makes ifdef-vs-comma easier. */
+
+const uschar *exim_sieve_extension_list[] = {
+ CUS"comparator-i;ascii-numeric",
+ CUS"copy",
+#ifdef ENCODED_CHARACTER
+ CUS"encoded-character",
+#endif
+#ifdef ENOTIFY
+ CUS"enotify",
+#endif
+ CUS"envelope",
+#ifdef ENVELOPE_AUTH
+ CUS"envelope-auth",
+#endif
+ CUS"fileinto",
+#ifdef SUBADDRESS
+ CUS"subaddress",
+#endif
+#ifdef VACATION
+ CUS"vacation",
+#endif
+ NULL
+};
+
static int eq_asciicase(const struct String *needle, const struct String *haystack, int match_prefix);
static int parse_test(struct Sieve *filter, int *cond, int exec);
static int parse_commands(struct Sieve *filter, int exec, address_item **generated);