Re: Allowing the default domain to be virtual

2004-06-16 Thread Simon Matter

   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..

Looks like a good idea to me.

Question to the cyrus developers: Is there a chance this patch will make
it into the distribution?

Simon


---
Cyrus Home Page: http://asg.web.cmu.edu/cyrus
Cyrus Wiki/FAQ: http://cyruswiki.andrew.cmu.edu
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html


Allowing the default domain to be virtual

2004-06-15 Thread Tore Anderson

  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;


Re: Allowing the default domain to be virtual

2004-06-15 Thread Denis V. Suhanov
H, correct me if I'm wrong, but doesn't 'defaultdomain' option do
that?

TA   Hi.  I want to set up a Cyrus IMAPd so that every domain is virtual,
TA  yet still allowing unqualified usernames to log in - in that case, they
TA  should be mapped into some default virtual domain.

TA   This isn't currently possible, is it?  I couldn't figure out how,
TA  anyway..  So I thought I'd implement a little something to make it
TA  possible.  Being lazy and all, I'd like to do it in a way that you'd be
TA  inclined to commit to the main distribution, so that I can simply use
TA  vendor-provided binaries from the next version on.

TA   So I've hacked together an example patch which seems to work for me,
TA  at least.  Comments solicited..

-- 
Best regards,
 Denismailto:[EMAIL PROTECTED]

---
Cyrus Home Page: http://asg.web.cmu.edu/cyrus
Cyrus Wiki/FAQ: http://cyruswiki.andrew.cmu.edu
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html


Re: Allowing the default domain to be virtual

2004-06-15 Thread Tore Anderson
* Tore Anderson

  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.

* Denis V. Suhanov

  H, correct me if I'm wrong, but doesn't 'defaultdomain' option
  do that?

  No, the defaultdomain option maps the user outside of the virtual
 domain setup altogether, instead of mapping him into the specified
 domain (if unqualified).  That makes Cyrus strip off the domain part of
 the username before passing it on to saslauthd for authentication.
 That's my problem - I need to have the entire qualified username
 available in saslauthd for an LDAP lookup, while still allowing the
 users in the primary domain to log in with unqualified users.  That's
 necessary as the current system I'm replacing with this Exim+Cyrus
 setup allows exactly that and there's quite some thousands of end users
 in the primary domain who've set up their MUA's to use unqualified
 addresses.  Changing that behaviour would be a support nightmare.

  So in other words my patch does user - [EMAIL PROTECTED]
 qualification, while the defaultdomain setting does
 [EMAIL PROTECTED] - user un-qualification.  At least that's
 how I understood it.

-- 
Tore Anderson
---
Cyrus Home Page: http://asg.web.cmu.edu/cyrus
Cyrus Wiki/FAQ: http://cyruswiki.andrew.cmu.edu
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html