Index: courier/libs/islocal.c
===================================================================
--- courier/libs/islocal.c	Sun Nov 23 14:06:13 2003
+++ courier/libs/islocal.c	Sun Nov 23 15:02:54 2003
@@ -10,4 +10,8 @@
 #include	<ctype.h>
 
+#ifndef ISLOCAL_MAX_DOT_COUNT
+#define ISLOCAL_MAX_DOT_COUNT 5
+#endif
+
 static const char rcsid[]="$Id: islocal.c,v 1.4 2001/01/16 06:01:47 mrsam Exp $";
 
@@ -79,6 +83,14 @@
 		*v=tolower((int)(unsigned char)*v);
 
-	v=dbobj_fetch(&db, k, kl, &vl, "");
-	free(k);
+	{
+	char	*lcaddress = k;
+	int	dotcount = 0;
+	while ((v=dbobj_fetch(&db, k, kl, &vl, "")) == NULL
+		&& (k = strchr(k+1,'.')) != NULL
+		&& dotcount++ < ISLOCAL_MAX_DOT_COUNT)
+		kl = strlen(k);
+	address += k-lcaddress;
+	free(lcaddress);
+	}
 	if (!v)	return (0);
 
Index: courier/doc/makehosteddomains.8.in
===================================================================
--- courier/doc/makehosteddomains.8.in	Mon Apr 21 17:00:10 2003
+++ courier/doc/makehosteddomains.8.in	Sun Nov 23 16:00:08 2003
@@ -108,4 +108,26 @@
 alias@example.com can be a clone of another account (with the same home
 directory, userid, and groupid).
+.SS "WILDCARD DNS"
+.PP
+Wildcard DNS is supported for hosteddomains by placing a single period
+character before the domain name. For example, the hosted domain entry
+".domain.com" will cause Courier to accept mail for "anything.domain.com".
+.PP
+Courier will accept mail for <address@any.thing.domain.com> and attempt
+to deliver it to the local mailbox <address@any.thing.domain.com>, 
+and if that fails then attempt to deliver the mail to the local 
+mailbox <address@.thing.domain.com>, then finally <address@.domain.com>
+.PP
+NOTE that there is a period after the '@' character. If you want all mail 
+for any.thing.domain.com to be delivered as though it were sent to domain.com, 
+you should define an alias for the domain, for example:
+.PP
+
+.nf
+ domain.com
+ .domain.com<TAB>domain.com
+.fi
+
+.PP
 .SH "SEE ALSO"
 .PP
Index: courier/doc/makehosteddomains.html.in
===================================================================
--- courier/doc/makehosteddomains.html.in	Sun Nov 23 15:33:48 2003
+++ courier/doc/makehosteddomains.html.in	Sun Nov 23 16:01:16 2003
@@ -330,4 +330,57 @@
 directory, userid, and groupid).</P
 ></DIV
+><H3
+>Wildcard DNS</H3
+><P
+>Wildcard DNS is supported for hosteddomains by placing a single period
+character before the domain name. For example, the hosted domain entry
+<TT   
+CLASS="LITERAL"
+>.domain.com</TT
+> will cause Courier to accept mail for <TT   
+CLASS="LITERAL"
+>anything.domain.com</TT
+>.</P
+><P
+>Courier will accept mail for <TT   
+CLASS="LITERAL"
+>address@any.thing.domain.com</TT
+> and attempt to deliver it to the local mailbox <TT
+CLASS="LITERAL"
+>address@any.thing.domain.com</TT
+>, and if that fails then attempt to deliver the
+mail to the local mailbox <TT   
+CLASS="LITERAL"
+>address@.thing.domain.com</TT
+>, then finally <TT
+CLASS="LITERAL"
+>address@.domain.com</TT
+>.<P
+>
+NOTE that there is a period after the '@' character. If you want all mail 
+for <TT   
+CLASS="LITERAL"
+>any.thing.domain.com</TT
+> to be delivered as though it were sent to <TT   
+CLASS="LITERAL"
+>domain.com</TT
+>, 
+you should define an alias for the domain, for example:</PRE
+><P
+></P
+><TABLE
+BORDER="0"
+BGCOLOR="#E0E0E0"
+WIDTH="100%"
+><TR
+><TD
+><PRE
+CLASS="PROGRAMLISTING"
+>domain.com
+.domain.com&#60;TAB&#62;domain.com</PRE
+></TD
+></TR
+></TABLE
+></DIV
 ></DIV
 ><DIV
@@ -353,3 +406,3 @@
 ></BODY
 ></HTML
->
\ No newline at end of file
+>
Index: ChangeLog
===================================================================
--- ChangeLog	Sun Nov 23 14:06:00 2003
+++ ChangeLog	Sun Nov 23 15:39:17 2003
@@ -1,2 +1,9 @@
+2003-11-23  Jeff Potter  <jpotter-courier@codepuppy.com>
+
+	* courier/libs/islocal.c: Added .domain.com checks so that hosteddomain
+	entries can support wildcard DNS.
+	* courier/doc/makehosteddomains.{8,html}.in: Added info on how to use
+	wildcard DNS with hosteddomains.
+
 2003-11-18  Tim Rice <tim@multitalents.net>
 
