diff options
Diffstat (limited to 'WWW/Library/Implementation/HTAccess.c')
-rw-r--r-- | WWW/Library/Implementation/HTAccess.c | 101 |
1 files changed, 66 insertions, 35 deletions
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c index 008d42b7..11dfc5ae 100644 --- a/WWW/Library/Implementation/HTAccess.c +++ b/WWW/Library/Implementation/HTAccess.c @@ -72,6 +72,7 @@ extern HTCJKlang HTCJK; PUBLIC char * HTClientHost = NULL; /* Name of remote login host if any */ PUBLIC FILE * HTlogfile = NULL; /* File to which to output one-liners */ PUBLIC BOOL HTSecure = NO; /* Disable access for telnet users? */ +PUBLIC BOOL HTPermitRedir = NO; /* Always allow redirection in getfile()? */ PUBLIC BOOL using_proxy = NO; /* are we using a proxy gateway? */ @@ -315,6 +316,9 @@ PUBLIC BOOL override_proxy ARGS1( #ifndef DISABLE_FINGER else if (!strcmp(acc_method, "finger")) port = 79; #endif + else if (!strcmp(acc_method, "telnet")) port = 23; + else if (!strcmp(acc_method, "tn3270")) port = 23; + else if (!strcmp(acc_method, "rlogin")) port = 513; FREE(acc_method); } } @@ -379,17 +383,34 @@ PRIVATE int get_physical ARGS2( char * acc_method = NULL; /* Name of access method */ char * physical = NULL; char * Server_addr = NULL; + BOOL override_flag = NO; + + /* + ** Make sure the using_proxy variable is FALSE. + */ + using_proxy = NO; #ifndef NO_RULES physical = HTTranslate(addr); if (!physical) { + if (redirecting_url) { + return HT_REDIRECTING; + } return HT_FORBIDDEN; } if (anchor->isISMAPScript == TRUE) { StrAllocCat(physical, "?0,0"); CTRACE(tfp, "HTAccess: Appending '?0,0' coordinate pair.\n"); } - HTAnchor_setPhysical(anchor, physical); + if (!strncmp(physical, "Proxied=", 8)) { + HTAnchor_setPhysical(anchor, physical + 8); + using_proxy = YES; + } else if (!strncmp(physical, "NoProxy=", 8)) { + HTAnchor_setPhysical(anchor, physical + 8); + override_flag = YES; + } else { + HTAnchor_setPhysical(anchor, physical); + } FREE(physical); /* free our copy */ #else if (anchor->isISMAPScript == TRUE) { @@ -410,53 +431,56 @@ PRIVATE int get_physical ARGS2( ** Check whether gateway access has been set up for this. ** ** This function can be replaced by the rule system above. + ** + ** If the rule system has already determined that we should + ** use a proxy, or that we shouldn't, ignore proxy-related + ** settings, don't use no_proxy either. */ #define USE_GATEWAYS #ifdef USE_GATEWAYS - /* - ** Make sure the using_proxy variable is FALSE. - */ - using_proxy = NO; - if (!strcasecomp(acc_method, "news")) { - /* - ** News is different, so we need to check the name of the server, - ** as well as the default port for selective exclusions. - */ - char *host = NULL; - if ((host = HTParse(addr, "", PARSE_HOST))) { - if (strchr(host, ':') == NULL) { + if (!override_flag && !using_proxy) { /* else ignore no_proxy env var */ + if (!strcasecomp(acc_method, "news")) { + /* + ** News is different, so we need to check the name of the server, + ** as well as the default port for selective exclusions. + */ + char *host = NULL; + if ((host = HTParse(addr, "", PARSE_HOST))) { + if (strchr(host, ':') == NULL) { + StrAllocCopy(Server_addr, "news://"); + StrAllocCat(Server_addr, host); + StrAllocCat(Server_addr, ":119/"); + } + FREE(host); + } else if (getenv("NNTPSERVER") != NULL) { StrAllocCopy(Server_addr, "news://"); - StrAllocCat(Server_addr, host); + StrAllocCat(Server_addr, (char *)getenv("NNTPSERVER")); StrAllocCat(Server_addr, ":119/"); } - FREE(host); - } else if (getenv("NNTPSERVER") != NULL) { - StrAllocCopy(Server_addr, "news://"); - StrAllocCat(Server_addr, (char *)getenv("NNTPSERVER")); - StrAllocCat(Server_addr, ":119/"); - } - } else if (!strcasecomp(acc_method, "wais")) { - /* + } else if (!strcasecomp(acc_method, "wais")) { + /* ** Wais also needs checking of the default port ** for selective exclusions. */ - char *host = NULL; - if ((host = HTParse(addr, "", PARSE_HOST))) { - if (!(strchr(host, ':'))) { - StrAllocCopy(Server_addr, "wais://"); - StrAllocCat(Server_addr, host); - StrAllocCat(Server_addr, ":210/"); + char *host = NULL; + if ((host = HTParse(addr, "", PARSE_HOST))) { + if (!(strchr(host, ':'))) { + StrAllocCopy(Server_addr, "wais://"); + StrAllocCat(Server_addr, host); + StrAllocCat(Server_addr, ":210/"); + } + FREE(host); } - FREE(host); - } - else + else + StrAllocCopy(Server_addr, addr); + } else { StrAllocCopy(Server_addr, addr); - } else { - StrAllocCopy(Server_addr, addr); + } + override_flag = override_proxy(Server_addr); } - if (!override_proxy(Server_addr)) { + if (!override_flag && !using_proxy) { char * gateway_parameter, *gateway, *proxy; /* @@ -641,11 +665,17 @@ PRIVATE int HTLoad ARGS4( HTProtocol *p; int status = get_physical(addr, anchor); if (status == HT_FORBIDDEN) { + /* prevent crash if telnet or similar was forbidden by rule. - kw */ + LYFixCursesOn("show alert:"); return HTLoadError(sink, 500, gettext("Access forbidden by rule")); + } else if (status == HT_REDIRECTING) { + return status; /* fake redirection by rule, to redirecting_url */ } if (status < 0) return status; /* Can't resolve or forbidden */ + /* prevent crash if telnet or similar mapped or proxied by rule. - kw */ + LYFixCursesOnForAccess(addr, HTAnchor_physical(anchor)); p = (HTProtocol *)HTAnchor_protocol(anchor); anchor->underway = TRUE; /* Hack to deal with caching */ status= (*(p->load))(HTAnchor_physical(anchor), @@ -668,6 +698,8 @@ PUBLIC HTStream *HTSaveStream ARGS1( return (*p->saveStream)(anchor); } +PUBLIC int redirection_attempts = 0; /* counter in HTLoadDocument */ + /* Load a document - with logging etc HTLoadDocument() ** ---------------------------------- ** @@ -697,7 +729,6 @@ PRIVATE BOOL HTLoadDocument ARGS4( CONST char * address_to_load = full_address; char *cp; BOOL ForcingNoCache = LYforce_no_cache; - static int redirection_attempts = 0; CTRACE (tfp, "HTAccess: loading document %s\n", address_to_load); |