From b79a17423c0f3dcaa13b31203c2e94b39697e847 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 28 Jan 2009 04:46:51 +0000 Subject: [PATCH] * If an address matches both a 'masq domain' and a 'directory domain', IsDirectory() now returns it as a directory domain regardless of which order they appear in the configuration. This fixes a problem found earlier today on a site that had overlapping domain declarations, and entries weren't being added to the directory index. * Also fixed the log message that displays when adding an entry to the directory index; now it only displays if the entry was actually written. --- citadel/internet_addressing.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index 26b8720a3..97a641cea 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -295,6 +295,7 @@ int CtdlHostAlias(char *fqdn) { int i; char buf[256]; char host[256], type[256]; + int found = 0; if (fqdn == NULL) return(hostalias_nomatch); if (IsEmptyStr(fqdn)) return(hostalias_nomatch); @@ -309,18 +310,23 @@ int CtdlHostAlias(char *fqdn) { extract_token(host, buf, 0, '|', sizeof host); extract_token(type, buf, 1, '|', sizeof type); - if ( (!strcasecmp(type, "localhost")) - && (!strcasecmp(fqdn, host))) - return(hostalias_localhost); + found = 0; - if ( (!strcasecmp(type, "directory")) - && (!strcasecmp(fqdn, host))) - return(hostalias_directory); + /* Process these in a specific order, in case there are multiple matches. + * We want directory to override masq, for example. + */ - if ( (!strcasecmp(type, "masqdomain")) - && (!strcasecmp(fqdn, host))) - return(hostalias_masq); + if ( (!strcasecmp(type, "masqdomain")) && (!strcasecmp(fqdn, host))) { + found = hostalias_masq; + } + if ( (!strcasecmp(type, "localhost")) && (!strcasecmp(fqdn, host))) { + found = hostalias_localhost; + } + if ( (!strcasecmp(type, "directory")) && (!strcasecmp(fqdn, host))) { + found = hostalias_directory; + } + if (found) return(found); } return(hostalias_nomatch); @@ -892,14 +898,10 @@ void CtdlDirectoryInit(void) { void CtdlDirectoryAddUser(char *internet_addr, char *citadel_addr) { char key[SIZ]; - CtdlLogPrintf(CTDL_DEBUG, "Dir: %s --> %s\n", - internet_addr, citadel_addr); if (IsDirectory(internet_addr, 0) == 0) return; - + CtdlLogPrintf(CTDL_DEBUG, "Dir: %s --> %s\n", internet_addr, citadel_addr); directory_key(key, internet_addr); - - cdb_store(CDB_DIRECTORY, key, strlen(key), - citadel_addr, strlen(citadel_addr)+1 ); + cdb_store(CDB_DIRECTORY, key, strlen(key), citadel_addr, strlen(citadel_addr)+1 ); } -- 2.30.2