-const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.1.1.1 2001/05/15 13:58:58 oes Exp $";
+const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.3 2001/05/20 01:21:20 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
*
* Revisions :
* $Log: loadcfg.c,v $
+ * Revision 1.3 2001/05/20 01:21:20 jongfoster
+ * Version 2.9.4 checkin.
+ * - Merged popupfile and cookiefile, and added control over PCRS
+ * filtering, in new "permissionsfile".
+ * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
+ * file error you now get a message box (in the Win32 GUI) rather
+ * than the program exiting with no explanation.
+ * - Made killpopup use the PCRS MIME-type checking and HTTP-header
+ * skipping.
+ * - Removed tabs from "config"
+ * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
+ * - Bumped up version number.
+ *
+ * Revision 1.2 2001/05/17 23:01:01 oes
+ * - Cleaned CRLF's from the sources and related files
+ *
* Revision 1.1.1.1 2001/05/15 13:58:58 oes
* Initial import of version 2.9.3 source tree
*
const char *configfile = NULL;
const char *blockfile = NULL;
-const char *cookiefile = NULL;
+const char *permissions_file = NULL;
const char *forwardfile = NULL;
#ifdef ACL_FILES
const char *imagefile = NULL;
#endif /* def USE_IMAGE_LIST */
-#ifdef KILLPOPUPS
-const char *popupfile = NULL;
-int kill_all_popups = 0; /* Not recommended really ... */
-#endif /* def KILLPOPUPS */
+/*
+ * Permissions to use for URLs not in the permissions list.
+ */
+int default_permissions = PERMIT_RE_FILTER;
#ifdef PCRS
const char *re_filterfile = NULL;
-int re_filter_all = 0;
#endif /* def PCRS */
+#ifdef FAST_REDIRECTS
+int fast_redirects = 0;
+#endif /* def FAST_REDIRECTS */
+
#ifdef TRUST_FILES
const char *trustfile = NULL;
#endif /* def TRUST_FILES */
#endif /* ndef SPLIT_PROXY_ARGS */
int suppress_vanilla_wafer = 0;
-int add_forwarded = 0;
+int add_forwarded = 0;
struct list wafer_list[1];
struct list xtra_list[1];
* something a little more readable. This also makes changing the
* hash values easier if they should change or the hash algorthm changes.
* Use the included "hash" program to find out what the hash will be
- * for any string supplied on the command line.
+ * for any string supplied on the command line. (Or just put it in the
+ * config file and read the number from the error message in the log).
*/
#define hash_trustfile 56494766ul
#define hash_suppress_vanilla_wafer 3121233547ul
#define hash_wafer 89669ul
#define hash_add_header 237434619ul
-#define hash_cookiefile 247469766ul
+#define hash_permissions_file 3825730796lu /* "permissionsfile" */
#define hash_logfile 2114766ul
#define hash_blockfile 48845391ul
#define hash_imagefile 51447891ul
#define hash_listen_address 1255650842ul
#define hash_forwardfile 1268669141ul
#define hash_aclfile 1908516ul
-#define hash_popupfile 54623516ul
-#define hash_kill_all_popups 2311539906ul
#define hash_re_filterfile 3877522444ul
-#define hash_re_filter_all 3877521376ul
#define hash_user_agent 283326691ul
#define hash_referrer 10883969ul
#define hash_referer 2176719ul
#define hash_from 16264ul
+#define hash_fast_redirects 464873764lu
#define hash_hide_console 2048809870ul
#define hash_include_stats 2174146548ul
#define hash_suppress_blocklists 1948693308ul
char *p, *q;
FILE *configfp = NULL;
- configret = 0;
+ configret = 0; /* FIXME: This is obsolete, always 0. */
config_changed = 1;
log_error(LOG_LEVEL_INFO, "loading configuration file '%s':", configfile);
/* (Waste of memory [not quite a "leak"] here. The
- * last blockfile/popupfile/... etc will not be
+ * last blockfile/permissions file/... etc will not be
* unloaded until we load a new one. If the
- * block/popup/... feature has been disabled in
+ * block/... feature has been disabled in
* the new config file, then we're wasting some
* memory we could otherwise reclaim.
*/
* But leave changing the logfile until after we're done loading.
*/
- #ifdef JAR_FILES
+#ifdef JAR_FILES
if ( NULL != jar )
{
fclose( jar );
jar = NULL;
}
- #endif /* def JAR_FILES */
+#endif /* def JAR_FILES */
debug = 0;
multi_threaded = 1;
+ default_permissions = PERMIT_RE_FILTER;
+
#if defined(DETECT_MSIE_IMAGES) || defined(USE_IMAGE_LIST)
tinygif = 0;
freez((char *)tinygifurl);
hideConsole = 0;
#endif /*def _WIN_CONSOLE*/
-#ifdef PCRS
- re_filter_all = 0;
-#endif /* def PCRS */
-
-#ifdef KILLPOPUPS
- kill_all_popups = 0;
-#endif /* def KILLPOPUPS */
-
#ifdef TOGGLE
g_bToggleIJB = 1;
#endif
freez((char *)blockfile);
- freez((char *)cookiefile);
+ freez((char *)permissions_file);
freez((char *)forwardfile);
#ifdef ACL_FILES
freez((char *)jarfile);
#endif /* def JAR_FILES */
-#ifdef KILLPOPUPS
- freez((char *)popupfile);
-#endif /* def KILLPOPUPS */
-
#ifndef SPLIT_PROXY_ARGS
freez((char *)suppress_message);
#endif /* ndef SPLIT_PROXY_ARGS */
freez((char *)re_filterfile);
#endif /* def PCRS */
+#ifdef FAST_REDIRECTS
+ fast_redirects = 0;
+#endif /* def FAST_REDIRECTS */
+
if (NULL != configfile)
{
if ((configfp = fopen(configfile, "r")) == NULL)
{
- log_error(LOG_LEVEL_ERROR, "can't open configuration file '%s': %E",
+ log_error(LOG_LEVEL_FATAL, "can't open configuration file '%s': %E",
configfile);
- configret = 1;
- return;
+ /* Never get here - LOG_LEVEL_FATAL causes program exit */
}
}
enlist(xtra_list, arg);
continue;
- case hash_cookiefile :
- freez((char *)cookiefile);
- cookiefile = strdup(arg);
+ case hash_permissions_file :
+ freez((char *)permissions_file);
+ permissions_file = strdup(arg);
continue;
case hash_logfile :
continue;
#endif /* def ACL_FILES */
-#ifdef KILLPOPUPS
- case hash_popupfile :
- freez((char *)popupfile);
- popupfile = strdup(arg);
- continue;
-
- case hash_kill_all_popups :
- kill_all_popups = 1;
- continue;
-#endif /* def KILLPOPUPS */
-
#ifdef PCRS
case hash_re_filterfile :
freez((char *)re_filterfile);
re_filterfile = strdup(arg);
continue;
-
- case hash_re_filter_all :
- re_filter_all = 1;
- log_error(LOG_LEVEL_REF, "re_filter policy is %s.",
- re_filter_all ? "RADICAL" : "SEMI-SMART");
- continue;
#endif /* def PCRS */
case hash_user_agent :
from = strdup(arg);
continue;
+#ifdef FAST_REDIRECTS
+ case hash_fast_redirects :
+ fast_redirects = 1;
+ continue;
+#endif /* def FAST_REDIRECTS */
+
#ifdef _WIN_CONSOLE
case hash_hide_console :
hideConsole = 1;
#endif /* ndef USE_IMAGE_LIST */
#ifndef PCRS
case hash_re_filterfile :
- case hash_re_filter_all :
#endif /* ndef PCRS */
#ifndef TOGGLE
case hash_toggle :
#if !defined(DETECT_MSIE_IMAGES) && !defined(USE_IMAGE_LIST)
case hash_tinygif :
#endif /* !defined(DETECT_MSIE_IMAGES) && !defined(USE_IMAGE_LIST) */
-#ifndef KILLPOPUPS
- case hash_popupfile :
- case hash_kill_all_popups :
-#endif /* ndef KILLPOPUPS */
#ifndef JAR_FILES
case hash_jarfile :
#endif /* ndef JAR_FILES */
continue;
default :
+ /*
+ * I decided that I liked this better as a warning than an
+ * error. To change back to an error, just change log level
+ * to LOG_LEVEL_FATAL.
+ */
log_error(LOG_LEVEL_ERROR, "Unrecognized directive (%lulu) in "
"configuration file: \"%s\"", hash_string( cmd ), buf);
p = malloc( BUFSIZ );
proxy_args->invocation = strsav( proxy_args->invocation, p );
freez( p );
}
- /*
- * I decided that I liked this better as a warning than an
- * error.
- */
-
- /*
- * configret = 1;
- * return;
- */
continue;
}
}
init_error_log(Argv[0], logfile, debug);
- if (cookiefile)
+ if (permissions_file)
{
- add_loader(load_cookiefile);
+ add_loader(load_permissions_file);
}
if (blockfile)
}
#endif /* def ACL_FILES */
-#ifdef KILLPOPUPS
- if (popupfile)
- {
- add_loader(load_popupfile);
- }
-#endif /* def KILLPOPUPS */
-
#ifdef PCRS
if (re_filterfile)
{
{
if ( NULL == (jar = fopen(jarfile, "a")) )
{
- log_error(LOG_LEVEL_ERROR, "can't open jarfile '%s': %E", jarfile);
- configret = 1;
- return;
+ log_error(LOG_LEVEL_FATAL, "can't open jarfile '%s': %E", jarfile);
+ /* Never get here - LOG_LEVEL_FATAL causes program exit */
}
setbuf(jar, NULL);
}
if (hport <= 0)
{
*--p = ':';
- log_error(LOG_LEVEL_ERROR, "invalid bind port spec %s", haddr);
- configret = 1;
- return;
+ log_error(LOG_LEVEL_FATAL, "invalid bind port spec %s", haddr);
+ /* Never get here - LOG_LEVEL_FATAL causes program exit */
}
if (*haddr == '\0')
{
if (run_loader(NULL))
{
- configret = 1;
- return;
+ log_error(LOG_LEVEL_FATAL, "A loader failed while loading config file. Exiting.");
+ /* Never get here - LOG_LEVEL_FATAL causes program exit */
}
#ifdef JAR_FILES