1f03e816acab7acbfdf91cd6fd9c9ac53922b874 larrym Wed Apr 27 09:05:51 2011 -0700 make hHostHasPrefix work when run from command line in a non-csh shell diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c index fd6b25a..16f2264 100644 --- src/hg/lib/hdb.c +++ src/hg/lib/hdb.c @@ -3057,37 +3057,38 @@ { struct hash *hash = NULL; struct hashEl *hel = NULL; hash = tableListGetDbHash(db); hel = hashLookup(hash, rootName); if (hel == NULL) return NULL; else return slNameCloneList((struct slName *)(hel->val)); } boolean hHostHasPrefix(char *prefix) /* Return TRUE if this is running on web-server with host name prefix */ { +char host[256]; if (prefix == NULL) return FALSE; char *httpHost = getenv("HTTP_HOST"); -if (httpHost == NULL) +if (httpHost == NULL && !gethostname(host, sizeof(host))) // make sure this works when CGIs are run from the command line. - httpHost = getenv("HOST"); + httpHost = host; if (httpHost == NULL) return FALSE; return startsWith(prefix, httpHost); } boolean hIsPrivateHost() /* Return TRUE if this is running on private (development) web-server. * This was originally genome-test as well as hgwdev, however genome-test * may be repurposed to direct users to the preview site instead of development site. */ { return hHostHasPrefix("hgwdev") || hHostHasPrefix("genome-test"); // FIXME: If genome-test }