I'm interested in the domain autofill feature to start deploying it for some to make it easier for people to remember easy ways to get to the qmailadmin program by providing a hostname under their domain name.

However in doing so, I noticed that this then autofilled the company's domain name in for most users who access it through the normal method.  The user then has to delete that and enter in their own domain.  Essentially one solution is to have two copies, one for others to access by any domain (put on an IP with many A records to it) and one on the main address without autofill on.

I have attached to this message my domain autofill exceptions patch against qmailadmin 1.2.10.  This changes the config.h line to inclued a pipe-separated list of hostnames for which it should not even try to autofill.  I'd imagine this could be easily added to the configure script to optionally accept a parameter.

If the #define string is a single character (like a "1") it will not do this check, so it could work even without a list of domains if it were to be included in the main distribution, which I'd love to see.  Otherwise hopefully this helps someone.

Best,
-M

--- ../orig/qmailadmin-1.2.10/template.c	2005-01-23 12:35:12.000000000 -0500
+++ template.c	2006-03-04 14:20:47.623531808 -0500
@@ -833,7 +833,27 @@
    if( fs != NULL ) {
       if ((srvnam = getenv("HTTP_HOST")) != NULL) {
          lowerit(srvnam);
-         while( fgets(TmpBuf, sizeof(TmpBuf), fs) != NULL && count==0 ) {
+	 if (strlen(DOMAIN_AUTOFILL) > 1) {
+		 char *domainlist;
+		 char *delim;
+		 char *currenttoken;
+		 domainlist = malloc(strlen(DOMAIN_AUTOFILL)+1 * sizeof(char));
+		 strncpy(domainlist, DOMAIN_AUTOFILL, strlen(DOMAIN_AUTOFILL));
+		 delim = malloc ( 2 * sizeof(char) );
+		 strncpy(delim, "|", 1);
+		 currenttoken = strtok(domainlist, delim);
+		 while (currenttoken != NULL) {
+			 if (strcmp(currenttoken, srvnam) == 0) {
+				 count = 1;
+			 }
+			 currenttoken = strtok(NULL, delim);
+		 }
+		 free(domainlist);
+		 free(delim);
+		 free(currenttoken);
+	 }
+	 if (count == 0) {
+           while( fgets(TmpBuf, sizeof(TmpBuf), fs) != NULL && count==0 ) {
             /* strip off newline */
             l = strlen(TmpBuf); l--; TmpBuf[l] = 0;
             /* virtualdomains format:  "domain:domain", get to second one */
@@ -846,6 +866,7 @@
                count=1;
             }
          }
+	 }
          fclose(fs);
       }
    }
--- config.h.orig	2006-03-04 14:09:06.867447712 -0500
+++ config.h	2006-03-04 13:55:45.430002093 -0500
@@ -11,7 +11,7 @@
 
 /* "" */
-#define DOMAIN_AUTOFILL 1
+#define DOMAIN_AUTOFILL "www.mydomain.com|mailadmin.mydomain.com"
 

Reply via email to