Hi. I want to set up a Cyrus IMAPd so that every domain is virtual,
yet still allowing unqualified usernames to log in - in that case, they
should be mapped into some default virtual domain.
This isn't currently possible, is it? I couldn't figure out how,
anyway.. So I thought I'd implement a little something to make it
possible. Being lazy and all, I'd like to do it in a way that you'd be
inclined to commit to the main distribution, so that I can simply use
vendor-provided binaries from the next version on.
So I've hacked together an example patch which seems to work for me,
at least. Comments solicited..
--
Tore Anderson
diff -ruN cyrus-imapd-2.2.5/imap/global.c cyrus-imapd-2.2.5-hack/imap/global.c
--- cyrus-imapd-2.2.5/imap/global.c 2004-05-22 05:45:49.0 +0200
+++ cyrus-imapd-2.2.5-hack/imap/global.c 2004-06-15 23:18:36.0 +0200
@@ -367,6 +367,12 @@
}
if (config_virtdomains) {
+ if (!domain && config_virt_defdomain) {
+ snprintf(buf, sizeof(buf), "[EMAIL PROTECTED]", user, config_virt_defdomain);
+ user = buf;
+ domain = user + len;
+ len = strlen(user);
+ }
if (domain) {
if (config_defdomain && !strcasecmp(config_defdomain, domain+1)) {
*domain = '\0'; /* trim the default domain */
diff -ruN cyrus-imapd-2.2.5/lib/imapoptions cyrus-imapd-2.2.5-hack/lib/imapoptions
--- cyrus-imapd-2.2.5/lib/imapoptions 2004-05-25 02:03:05.0 +0200
+++ cyrus-imapd-2.2.5-hack/lib/imapoptions 2004-06-15 22:47:17.0 +0200
@@ -180,7 +180,10 @@
mailbox that does not have a parent mailbox. */
{ "defaultdomain", NULL, STRING }
-/* The default domain for virtual domain support */
+/* The default domain for virtual domain support. Messages to users in this
+ domain will be mapped outside of the virtual domain hierarchy, just as if
+ virtual domain support was turned off. Unqualified users are also mapped
+ into the default domain, unless "virtual_defaultdomain" is set. */
{ "defaultpartition", "default", STRING }
/* The partition name used by default for new mailboxes. */
@@ -832,6 +835,14 @@
interface, otherwise the user is assumed to be in the default
domain (if set). */
+{ "virtual_defaultdomain", NULL, STRING }
+/* Automatically map unqualified users into this virtual domain. This happens
+ before the user is mapped according to the setting of "defaultdomain", so
+ if they are both set to the same value, the user will in the end be mapped
+ into the (non-virtual) "defaultdomain", effectively making
+ "virtual_defaultdomain" a no-op. In other words, it makes no sense to do
+ so. */
+
/*
.SH SEE ALSO
.PP
diff -ruN cyrus-imapd-2.2.5/lib/libconfig.c cyrus-imapd-2.2.5-hack/lib/libconfig.c
--- cyrus-imapd-2.2.5/lib/libconfig.c 2004-05-22 05:45:54.0 +0200
+++ cyrus-imapd-2.2.5-hack/lib/libconfig.c 2004-06-15 22:30:58.0 +0200
@@ -71,6 +71,7 @@
const char *config_servername= NULL; /* gethostname() */
const char *config_mupdate_server = NULL;/* NULL */
const char *config_defdomain = NULL; /* NULL */
+const char *config_virt_defdomain = NULL;/* NULL */
const char *config_ident = NULL; /* the service name */
int config_hashimapspool; /* f */
enum enum_value config_virtdomains; /* f */
@@ -238,6 +239,7 @@
/* are we supporting virtual domains? */
config_virtdomains = config_getenum(IMAPOPT_VIRTDOMAINS);
config_defdomain = config_getstring(IMAPOPT_DEFAULTDOMAIN);
+config_virt_defdomain = config_getstring(IMAPOPT_VIRTUAL_DEFAULTDOMAIN);
/* look up the hostname we should present to the user */
config_servername = config_getstring(IMAPOPT_SERVERNAME);
diff -ruN cyrus-imapd-2.2.5/lib/libconfig.h cyrus-imapd-2.2.5-hack/lib/libconfig.h
--- cyrus-imapd-2.2.5/lib/libconfig.h 2003-12-29 21:22:55.0 +0100
+++ cyrus-imapd-2.2.5-hack/lib/libconfig.h 2004-06-15 23:09:28.0 +0200
@@ -66,6 +66,7 @@
extern const char *config_servername;
extern const char *config_mupdate_server;
extern const char *config_defdomain;
+extern const char *config_virt_defdomain;
extern const char *config_ident;
extern int config_hashimapspool;
extern int config_implicitrights;