* citserver.c: added another trace message to is_public_client(). Uncensored
authorArt Cancro <ajc@citadel.org>
Mon, 2 Jun 2003 03:01:23 +0000 (03:01 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 2 Jun 2003 03:01:23 +0000 (03:01 +0000)
  has crashed twice in this function, for no apparent reason.
* internet_addressing.c: don't attempt to look up the specified Internet
  address in a Citadel directory, if the supplied address has no hostname
  portion.  (Fixes a crash in the calendar service when alias() attempts to
  look up potentially nonexistent attendees during event validation)

citadel/ChangeLog
citadel/citserver.c
citadel/internet_addressing.c

index 9bfe0cae832f68324801328a8b86e2faf19d6c3a..d533073fa7bb158fab755cba270921539fca8709 100644 (file)
@@ -1,4 +1,12 @@
  $Log$
+ Revision 606.6  2003/06/02 03:01:22  ajc
+ * citserver.c: added another trace message to is_public_client().  Uncensored
+   has crashed twice in this function, for no apparent reason.
+ * internet_addressing.c: don't attempt to look up the specified Internet
+   address in a Citadel directory, if the supplied address has no hostname
+   portion.  (Fixes a crash in the calendar service when alias() attempts to
+   look up potentially nonexistent attendees during event validation)
+
  Revision 606.5  2003/05/28 03:08:38  ajc
  * msgbase.c: validate_recipients() now rejects Internet addresses in
    domains belonging to the local system or an attached Citadel network,
@@ -4734,3 +4742,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index 567468e1240d6cb7cacf220070eceaa03bb717b4..2694739fd8980a70941ba45169ceb8a38bb0b08c 100644 (file)
@@ -404,25 +404,28 @@ static int hostnames_match(const char *realname, const char *testname) {
 }
 
 /*
- * check a hostname against the public_clients file
+ * Check a hostname against the public_clients file.  This determines
+ * whether the client is allowed to change the hostname for this session
+ * (for example, to show the location of the user rather than the location
+ * of the client).
  */
 int is_public_client(char *where)
 {
        char buf[SIZ];
        FILE *fp;
 
-       lprintf(9, "Checking whether %s is a public client\n", where);
-
+       lprintf(9, "Checking whether %s is a local client\n", where);
        if (hostnames_match(where, "localhost")) return(1);
        if (hostnames_match(where, config.c_fqdn)) return(1);
 
-       fp = fopen("public_clients","r");
+       lprintf(9, "Checking whether %s is a public client\n", where);
+       fp = fopen("public_clients", "r");
        if (fp == NULL) return(0);
 
        while (fgets(buf, sizeof buf, fp)!=NULL) {
                while (isspace((buf[strlen(buf)-1]))) 
                        buf[strlen(buf)-1] = 0;
-               if (hostnames_match(where,buf)) {
+               if (hostnames_match(where, buf)) {
                        fclose(fp);
                        return(1);
                }
index ca45a4b09d144d0738a099892304ba0a6a5c6ece..c6837c38e63f2622d45825037117194464ea272a 100644 (file)
@@ -73,6 +73,8 @@ int CtdlHostAlias(char *fqdn) {
        char buf[SIZ];
        char host[SIZ], type[SIZ];
 
+       if (fqdn == NULL) return(hostalias_nomatch);
+       if (strlen(fqdn) == 0) return(hostalias_nomatch);
        if (!strcasecmp(fqdn, config.c_fqdn)) return(hostalias_localhost);
        if (!strcasecmp(fqdn, config.c_nodename)) return(hostalias_localhost);
        if (inetcfg == NULL) return(hostalias_nomatch);
@@ -629,6 +631,13 @@ int CtdlDirectoryLookup(char *target, char *internet_addr) {
        struct cdbdata *cdbrec;
        char key[SIZ];
 
+       /* Dump it in there unchanged, just for kicks */
+       strcpy(target, internet_addr);
+
+       /* Only do lookups for addresses with hostnames in them */
+       if (num_tokens(internet_addr, '@') != 2) return(-1);
+
+       /* Only do lookups for domains in the directory */
        if (IsDirectory(internet_addr) == 0) return(-1);
 
        directory_key(key, internet_addr);