]> andersk Git - mod-vhost-ldap.git/commitdiff
Simplify construction of wildcard hostnames.
authorAnders Kaseorg <andersk@mit.edu>
Fri, 7 Mar 2008 11:16:20 +0000 (11:16 +0000)
committerAnders Kaseorg <andersk@mit.edu>
Fri, 7 Mar 2008 11:16:20 +0000 (11:16 +0000)
git-svn-id: svn://scripts.mit.edu/server/common/oursrc/httpdmods@680 db9d59ff-b01e-0410-9b1a-cd9a8c06840f

mod_vhost_ldap.c

index bc9893f919f9c982d5dd39f9186afb00599c6b5c..3282e8f5f85a24af4499d36f63ae25137a90aeae 100644 (file)
@@ -507,17 +507,15 @@ fallback:
     }
 
     if ((result == LDAP_NO_SUCH_OBJECT)) {
-       char* parent_hostname = apr_pstrdup(r->pool, hostname);
-       do {
-           parent_hostname = strchr(parent_hostname + 1, '.');
-       } while (parent_hostname && parent_hostname[-1] != '*');
-       if (parent_hostname) {
-           *(--parent_hostname) = '*';
+       if (strcmp(hostname, "*") != 0) {
+           if (strncmp(hostname, "*.", 2) == 0)
+               hostname += 2;
+           hostname += strcspn(hostname, ".");
+           hostname = apr_pstrcat(r->pool, "*", hostname, NULL);
            ap_log_rerror(APLOG_MARK, APLOG_NOTICE|APLOG_NOERRNO, 0, r,
                          "[mod_vhost_ldap.c] translate: "
                          "virtual host not found, trying wildcard %s",
-                         parent_hostname);
-           hostname = parent_hostname;
+                         hostname);
            goto fallback;
        }
 
This page took 0.159405 seconds and 5 git commands to generate.