From: jongfoster Date: Sun, 20 May 2001 01:21:20 +0000 (+0000) Subject: Version 2.9.4 checkin. X-Git-Tag: v_2_9_9~519 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=87a69fc505def6be1c8a4d24ae225c3623b5e861 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. --- diff --git a/config b/config index fbc5321f..b5b39754 100644 --- a/config +++ b/config @@ -1,15 +1,15 @@ # Sample Configuration file for the Internet Junkbuster 2.0 # -# $Id: config,v 1.2 2001/04/30 03:05:11 rodney Exp $ +# $Id: config,v 1.2 2001/05/17 22:37:46 oes Exp $ # # Table of Contents # -# 1. INTRODUCTION +# 1. INTRODUCTION # 2. FORMAT OF THE CONFIGURATION FILE # 3. OTHER CONFIGURATION FILES -# 4. GENERAL OPTIONS +# 4. GENERAL OPTIONS # 5. WINDOWS GUI OPTIONS # # 1. INTRODUCTION @@ -63,7 +63,7 @@ # # Default: Don't block anything. # -blockfile ./blocklist +blockfile ./blocklist # # The imagefile contains regular expressions, one per line, of URLs @@ -72,15 +72,17 @@ blockfile ./blocklist # # Default: Block all URLs as HTML requests. # -imagefile ./imagelist +imagefile ./imagelist # -# The popfile contains regular expressions, one per line, of sites -# where Junkbuster should disable Javascript popups. +# The permissions file contains patterns to specify the +# cookie and filtering rules to apply to each site. # -# Default: No popup filtering. +# Default: Cookies to and from all destinations are filtered. +# Popups are disabled for all sites. +# All sites are filtered if re_filterfile specified. # -popupfile ./popup +permissionsfile ./permissionsfile # # The re_filterfile contains content modification rules. These rules @@ -91,18 +93,7 @@ popupfile ./popup # # Default: No content modification. # -re_filterfile ./re_filterfile - -# -# The cookiefile defines how Junkbuster should treat cookies: filter -# them out; permit them; permit them only one-way from your browser -# to the site, etc. You can set this on a site-by-site basis, so -# that you can, for example, use cookies at sites you trust while -# filtering them out everywhere else. -# -# Default: Cookies to and from all destinations are filtered. -# -cookiefile ./cookiefile +re_filterfile ./re_filterfile # # The logfile is where all logging and error messages are written. @@ -122,7 +113,7 @@ cookiefile ./cookiefile # # Default: Log to the standard error channel, not to a file # -logfile ./junkbuster.log +logfile ./junkbuster.log # # The jarfile defines where Junkbuster stores the cookies it @@ -131,7 +122,7 @@ logfile ./junkbuster.log # # Default: Don't store intercepted cookies # -#jarfile ./jarfile +#jarfile ./jarfile # # The forwardfile defines domain-specific forwarding of HTTP @@ -142,7 +133,7 @@ logfile ./junkbuster.log # # Default: Make all connections directly. # -forwardfile ./forward +forwardfile ./forward # # Generally, Junkbuster is used as a personal proxy. The default @@ -160,7 +151,7 @@ forwardfile ./forward # Default: No access control. Everybody that can reach junkbuster # will be served. # -#aclfile ./aclfile +#aclfile ./aclfile # # 4. OPTIONS @@ -169,15 +160,6 @@ forwardfile ./forward # how Junkbuster operates. # -# -# If 're_filter_all' is set, (commented in) Junkbuster will attempt -# content modification (see 're_filterfile' above) on all requests. -# -# Default: Content modification takes only place if no cookie would -# be sent to the server. -# -#re_filter_all - # # If 'add-forwarded-header' is set, an "X-Forwarded-For:" # specification will be added to each request header. Generally, @@ -310,8 +292,8 @@ user-agent . # # VALUE EFFECT # ===== ====== -# default Kill the referrer-header from the client. -# . Pass the referrer unchanged. +# default Kill the referrer-header from the client. +# . Pass the referrer unchanged. # @ Pass the referrer if the server is in the cookie file, # kill the referrer otherwise. # L Pass the referrer if the server is in the cookie file, @@ -324,7 +306,7 @@ user-agent . # # Default: see above # -referer L +referer L # # Some browsers provide a "From:" header that gives Web sites your @@ -340,7 +322,7 @@ referer L # # Default: see above # -from spam-me-senseless@sittingduck.xqq +#from spam-me-senseless@sittingduck.xqq # # The 'tinygif' option lets you change how Junkbuster treats blocked @@ -350,10 +332,10 @@ from spam-me-senseless@sittingduck.xqq # # VALUE EFFECT # ===== ====== -# 0 Send HTML -# 1 Send a GIF of one transparent pixel -# 2 Send a GIF with the word "JUNKBUSTER" -# 3 Send a redirect to the image indicated by the +# 0 Send HTML +# 1 Send a GIF of one transparent pixel +# 2 Send a GIF with the word "JUNKBUSTER" +# 3 Send a redirect to the image indicated by the # # As an example of the last option: # @@ -369,7 +351,7 @@ from spam-me-senseless@sittingduck.xqq # # Default: 0, i.e. send HTML # -tinygif 2 +tinygif 2 # # The debug option sets the level of debugging information to log in @@ -393,7 +375,7 @@ tinygif 2 # # Default: 0, i.e. log nothing but errors and infos # -debug 1 +debug 1 # # Junkbuster normally uses "multi-threading", a software technique @@ -455,13 +437,13 @@ toggle 1 # Warning: Setting this to 0 will result in the buffer to grow # infinitely and eat up all your memory! # -#Win32-only: log-buffer-size 1 +#Win32-only: log-buffer-size 1 -# log-max-lines {number of lines, e.g., '200'} +# log-max-lines {number of lines, e.g., '200'} # # Maximum number of lines held in the log buffer. See above. # -#Win32-only: log-max-lines 200 +#Win32-only: log-max-lines 200 # log-highlight-messages {1 or 0} # diff --git a/config.h b/config.h index 4d71f86b..a435e9ea 100644 --- a/config.h +++ b/config.h @@ -4,7 +4,7 @@ #define _CONFIG_H /********************************************************************* * - * File : $Source: /home/administrator/cvs/ijb/acconfig.h,v $ + * File : $Source: /cvsroot/ijbswa/current/config.h,v $ * * Purpose : This file should be the first thing included in every * .c file. (Before even system headers). It contains @@ -38,7 +38,10 @@ * Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Revisions : - * $Log: acconfig.h,v $ + * $Log: config.h,v $ + * Revision 1.1.1.1 2001/05/15 13:58:49 oes + * Initial import of version 2.9.3 source tree + * * *********************************************************************/ @@ -65,12 +68,12 @@ /* * Version number - Point (_._.X) */ -#define VERSION_POINT 3 +#define VERSION_POINT 4 /* * Version number, as a string */ -#define VERSION "2.9.3" +#define VERSION "2.9.4" /* * Regular expression matching for URLs. (Highly recommended). If this is diff --git a/configure b/configure index 6c620ec3..95567ece 100755 --- a/configure +++ b/configure @@ -562,7 +562,7 @@ fi VERSION_MAJOR=2 VERSION_MINOR=9 -VERSION_POINT=3 +VERSION_POINT=4 diff --git a/configure.in b/configure.in index 492d6edc..808b3970 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. dnl -dnl $Id: configure.in,v 1.2 2001/05/13 22:04:51 administrator Exp $ +dnl $Id: configure.in,v 1.1.1.1 2001/05/15 13:58:50 oes Exp $ dnl dnl Written by and Copyright (C) 2001 the SourceForge dnl IJBSWA team. http://ijbswa.sourceforge.net @@ -28,13 +28,16 @@ dnl or write to the Free Software Foundation, Inc., 59 dnl Temple Place - Suite 330, Boston, MA 02111-1307, USA. dnl dnl $Log: configure.in,v $ +dnl Revision 1.1.1.1 2001/05/15 13:58:50 oes +dnl Initial import of version 2.9.3 source tree +dnl dnl AC_INIT(jcc.c) AC_CONFIG_HEADER(config.h) VERSION_MAJOR=2 VERSION_MINOR=9 -VERSION_POINT=3 +VERSION_POINT=4 AC_SUBST(VERSION_MAJOR) AC_SUBST(VERSION_MINOR) diff --git a/cookiefile b/cookiefile deleted file mode 100644 index f17f4b0c..00000000 --- a/cookiefile +++ /dev/null @@ -1,67 +0,0 @@ -# -# This is /etc/junkbuster/cookefile which was put here by a junkbuster rpm -# -# Last modified on Sun Jan 31 22:36:03 1999 (CEST) -# -# -------------------------------------------------------------------------- -# -# Newest version is always available from -# -# http://www.waldherr.org/cookiefile -# -# Read http://www.waldherr.org/junkbuster/update.shtml on how to keep -# this file up-to-date. -# -# For more detail, see http://www.junkbusters.com/ht/en/ijbfaq.html#cookies -# -# Empty lines and lines beginning with a # are ignored. -# To permit an entire site to set cookies, simply include its domain name: -# really-trustyworthy-people.org -# -# You can allow cookies out, but stop them coming in: -# >send-user-cookies.com -# -#>egroups.com -#>tvguide.com -#>wired.com/news/ -#americanexpress.com -#cnn.com -#www.nytimes.com -#yahoo.com -#amazon.de -#amazon.co.uk -#slashdot.org -#www.palmgear.com -#onelist.com -#freshmeat.net - -# Sites that need cookies -javasoft.com -sun.com -msdn.microsoft.com -sourceforge.net -yahoo.com -anonymizer.com - -# Experimenting -ashleycars.co.uk - -# Shopping -dabs.com -overclockers.co.uk -worldpay.com # for quietpc.com -jungle.com -scan.co.uk - -#Shopping: Micro Warehouse's site -#inmac.co.uk -#technomatic.co.uk - -# This is stupid. Without these two entries, the link from McAfee's website -# to their online UK shop gives a 500 server error. -#mcafee.com -#mcafeestoreuk.beyond.com - - - - diff --git a/filters.c b/filters.c index 29cee478..d1262186 100644 --- a/filters.c +++ b/filters.c @@ -1,12 +1,12 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.1 2001/05/13 21:57:06 administrator Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.1.1.1 2001/05/15 13:58:52 oes Exp $"; /********************************************************************* * - * File : $Source: /home/administrator/cvs/ijb/filters.c,v $ + * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ * * Purpose : Declares functions to parse/crunch headers and pages. * Functions declared include: * `acl_addr', `add_stats', `block_acl', `block_imageurl', - * `block_url', `cookie_url', `domaincmp', `dsplit', + * `block_url', `url_permissions', `domaincmp', `dsplit', * `filter_popups', `forward_url', * `ij_untrusted_url', `intercept_url', `re_process_buffer', * `show_proxy_args', and `trust_url' @@ -38,6 +38,9 @@ const char filters_rcs[] = "$Id: filters.c,v 1.1 2001/05/13 21:57:06 administrat * * Revisions : * $Log: filters.c,v $ + * Revision 1.1.1.1 2001/05/15 13:58:52 oes + * Initial import of version 2.9.3 source tree + * * *********************************************************************/ @@ -494,7 +497,10 @@ void re_process_buffer(struct client_state *csp) struct re_filterfile_spec *b; /* Sanity first ;-) */ - if (size <= 0) return; + if (size <= 0) + { + return; + } if ( ( NULL == (fl = csp->rlist) ) || ( NULL == (b = fl->f) ) ) { @@ -505,7 +511,7 @@ void re_process_buffer(struct client_state *csp) joblist = b->joblist; - log_error(LOG_LEVEL_REF, "re_filtering %s%s (size %d) ...", + log_error(LOG_LEVEL_RE_FILTER, "re_filtering %s%s (size %d) ...", csp->http->hostport, csp->http->path, size); /* Apply all jobs from the joblist */ @@ -516,7 +522,7 @@ void re_process_buffer(struct client_state *csp) old=new; } - log_error(LOG_LEVEL_REF, " produced %d hits (new size %d).", hits, size); + log_error(LOG_LEVEL_RE_FILTER, " produced %d hits (new size %d).", hits, size); if (write_socket(csp->cfd, old, size) != size) { @@ -789,32 +795,36 @@ char *intercept_url(struct http_request *http, struct client_state *csp) /********************************************************************* * - * Function : cookie_url + * Function : url_permissions * - * Description : Accept this cookie, or no? See "cookiefile" setting. + * Description : Gets the permissions for this URL. * * Parameters : * 1 : http = http_request request for blocked URLs * 2 : csp = Current client state (buffers, headers, etc...) * - * Returns : NULL => accept, cookie_spec pointer to crunch. + * Returns : permissions bitmask specifiying what this URL can do. + * If not on list, will be default_permissions. * *********************************************************************/ -struct cookie_spec *cookie_url(struct http_request *http, struct client_state *csp) +int url_permissions(struct http_request *http, struct client_state *csp) { struct file_list *fl; - struct cookie_spec *b; + struct permissions_spec *b; struct url_spec url[1]; - if (((fl = csp->clist) == NULL) || ((b = fl->f) == NULL)) + if (((fl = csp->permissions_list) == NULL) || ((b = fl->f) == NULL)) { - return(NULL); + return(default_permissions); } *url = dsplit(http->host); /* if splitting the domain fails, punt */ - if (url->dbuf == NULL) return(NULL); + if (url->dbuf == NULL) + { + return(default_permissions); + } for (b = b->next; NULL != b; b = b->next) { @@ -832,7 +842,7 @@ struct cookie_spec *cookie_url(struct http_request *http, struct client_state *c { freez(url->dbuf); freez(url->dvec); - return(b); + return(b->permissions); } } } @@ -840,7 +850,7 @@ struct cookie_spec *cookie_url(struct http_request *http, struct client_state *c freez(url->dbuf); freez(url->dvec); - return(NULL); + return(default_permissions); } @@ -1055,11 +1065,11 @@ char *show_proxy_args(struct http_request *http, struct client_state *csp) file_description = "Block List"; } break; - case 'c': - if (csp->clist) + case 'p': + if (csp->permissions_list) { - filename = csp->clist->filename; - file_description = "Cookie List"; + filename = csp->permissions_list->filename; + file_description = "Permissions List"; } break; case 'f': @@ -1090,16 +1100,6 @@ char *show_proxy_args(struct http_request *http, struct client_state *csp) break; #endif /* def USE_IMAGE_LIST */ -#ifdef KILLPOPUPS - case 'p': - if (csp->plist) - { - filename = csp->plist->filename; - file_description = "Popup list"; - } - break; -#endif /* def KILLPOPUPS */ - #ifdef PCRS case 'r': if (csp->rlist) @@ -1222,10 +1222,10 @@ char *show_proxy_args(struct http_request *http, struct client_state *csp) s = strsav(s, "\n"); } - if (csp->clist) + if (csp->permissions_list) { - s = strsav(s, "
  • Cookie List: "); - s = strsav(s, csp->clist->filename); + s = strsav(s, "
  • Permissions List: "); + s = strsav(s, csp->permissions_list->filename); s = strsav(s, "
  • \n"); } @@ -1253,16 +1253,7 @@ char *show_proxy_args(struct http_request *http, struct client_state *csp) s = strsav(s, "\n"); } #endif /* def USE_IMAGE_LIST */ - -#ifdef KILLPOPUPS - if (csp->plist) - { - s = strsav(s, "
  • Popup List: "); - s = strsav(s, csp->plist->filename); - s = strsav(s, "
  • \n"); - } -#endif /* def KILLPOPUPS */ - + #ifdef PCRS if (csp->rlist) { @@ -1313,13 +1304,6 @@ char *show_proxy_args(struct http_request *http, struct client_state *csp) } #endif /* def USE_IMAGE_LIST */ -#ifdef KILLPOPUPS - if (csp->plist) - { - s = strsav(s, csp->plist->proxy_args); - } -#endif /* def KILLPOPUPS */ - #ifdef PCRS if (csp->rlist) { diff --git a/filters.h b/filters.h index 68af5195..a510ddf4 100644 --- a/filters.h +++ b/filters.h @@ -1,14 +1,14 @@ #ifndef _FILTERS_H #define _FILTERS_H -#define FILTERS_H_VERSION "$Id: filters.h,v 1.1 2001/05/13 21:57:06 administrator Exp $" +#define FILTERS_H_VERSION "$Id: filters.h,v 1.1.1.1 2001/05/15 13:58:52 oes Exp $" /********************************************************************* * - * File : $Source: /home/administrator/cvs/ijb/filters.h,v $ + * File : $Source: /cvsroot/ijbswa/current/filters.h,v $ * * Purpose : Declares functions to parse/crunch headers and pages. * Functions declared include: * `acl_addr', `add_stats', `block_acl', `block_imageurl', - * `block_url', `cookie_url', `domaincmp', `dsplit', + * `block_url', `url_permissions', `domaincmp', `dsplit', * `filter_popups', `forward_url' * `ij_untrusted_url', `intercept_url', `re_process_buffer', * `show_proxy_args', and `trust_url' @@ -40,6 +40,9 @@ * * Revisions : * $Log: filters.h,v $ + * Revision 1.1.1.1 2001/05/15 13:58:52 oes + * Initial import of version 2.9.3 source tree + * * *********************************************************************/ @@ -69,7 +72,7 @@ extern int block_imageurl(struct http_request *http, struct client_state *csp); extern int block_imageurl_using_imagelist(struct http_request *http, struct client_state *csp); #endif /* def USE_IMAGE_LIST */ -extern struct cookie_spec *cookie_url(struct http_request *http, struct client_state *csp); +extern int url_permissions(struct http_request *http, struct client_state *csp); extern const struct gateway *forward_url(struct http_request *http, struct client_state *csp); extern struct url_spec dsplit(char *domain); diff --git a/jcc.c b/jcc.c index f167a8b8..a5812121 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.1.1.1 2001/05/15 13:58:56 oes Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.2 2001/05/17 22:34:44 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -33,6 +33,11 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.1.1.1 2001/05/15 13:58:56 oes Exp $"; * * Revisions : * $Log: jcc.c,v $ + * Revision 1.2 2001/05/17 22:34:44 oes + * - Added hint on GIF char array generation to jcc.c + * - Cleaned CRLF's from the sources and related files + * - Repaired logging for REF and FRC + * * Revision 1.1.1.1 2001/05/15 13:58:56 oes * Initial import of version 2.9.3 source tree * @@ -229,16 +234,37 @@ static const char FWGIF[] = *********************************************************************/ static void chat(struct client_state *csp) { +/* This next line is a little ugly, but it simplifies the if statement below. */ +/* Basically if TOGGLE, then we want the if to test "csp->toggled_on", else we don't */ +#ifdef TOGGLE +# define IS_TOGGLED_ON csp->toggled_on && +#else /* ifndef TOGGLE */ +# define IS_TOGGLED_ON +#endif /* ndef TOGGLE */ + +/* This next line is a little ugly, but it simplifies the if statement below. */ +/* Basically if TRUST_FILES, then we want the if to call "trust_url", else we don't */ +#ifdef TRUST_FILES +# define IS_TRUSTED_URL (p = trust_url(http, csp)) || +#else /* ifndef TRUST_FILES */ +# define IS_TRUSTED_URL +#endif /* ndef TRUST_FILES */ + + char buf[BUFSIZ], *hdr, *p, *req; char *err = NULL; char *eno; fd_set rfds; int n, maxfd, server_body, ms_iis5_hack = 0; - struct cookie_spec *cs; const struct gateway *gw; - struct http_request *http; + struct http_request *http; +#ifdef KILLPOPUPS + int block_popups; /* bool, 1==will block popups */ + int block_popups_now = 0; /* bool, 1==currently blocking popups */ +#endif /* def KILLPOPUPS */ #ifdef PCRS - int filtering = 0; + int pcrs_filter; /* bool, 1==will filter through pcrs */ + int filtering = 0; /* bool, 1==currently filtering through pcrs */ #endif /* def PCRS */ http = csp->http; @@ -276,7 +302,7 @@ static void chat(struct client_state *csp) if(strstr(req, FORCE_PREFIX)) { strclean(req, FORCE_PREFIX); - log_error(LOG_LEVEL_FRC, "Enforcing request \"%s\".\n", req); + log_error(LOG_LEVEL_FORCE, "Enforcing request \"%s\".\n", req); csp->force = 1; } else @@ -301,8 +327,8 @@ static void chat(struct client_state *csp) if ((gw = forward_url(http, csp)) == NULL) { - log_error(LOG_LEVEL_ERROR, "gateway spec is NULL!?!? This can't happen!"); - abort(); + log_error(LOG_LEVEL_FATAL, "gateway spec is NULL!?!? This can't happen!"); + /* Never get here - LOG_LEVEL_FATAL causes program exit */ } /* build the http request to send to the server @@ -350,32 +376,31 @@ static void chat(struct client_state *csp) freez(p); } } - + /* decide what we're to do with cookies */ - -#if defined(TOGGLE) - /* - * by haroon - most of credit to srt19170 - * if toggled_on flag is false IJB is disabled, pass cookies thru - */ - if (!csp->toggled_on) - { - csp->accept_server_cookie = 1; - csp->send_user_cookie = 1; - } - else -#endif - - if ((cs = cookie_url(http, csp))) - { - csp->accept_server_cookie = cs->accept_server_cookie; - csp->send_user_cookie = cs->send_user_cookie; - } - else - { - csp->accept_server_cookie = 0; - csp->send_user_cookie = 0; - } + +#ifdef TOGGLE + if (!csp->toggled_on) + { + /* Most compatible set of permissions */ + csp->permissions = PERMIT_COOKIE_SET | PERMIT_COOKIE_READ | PERMIT_POPUPS; + } + else + { + csp->permissions = url_permissions(http, csp); + } +#else /* ifndef TOGGLE */ + csp->permissions = url_permissions(http, csp); +#endif /* ndef TOGGLE */ + +#ifdef KILLPOPUPS + block_popups = ((csp->permissions & PERMIT_POPUPS) == 0); +#endif /* def KILLPOPUPS */ +#ifdef PCRS + pcrs_filter = (csp->rlist != NULL) && /* There are expressions to be used */ + ((csp->permissions & PERMIT_RE_FILTER) != 0); +#endif /* def PCRS */ + /* grab the rest of the client's headers */ @@ -405,37 +430,12 @@ static void chat(struct client_state *csp) destroy_list(csp->headers); -#ifdef TOGGLE - /* - * by haroon - most of credit to srt19170 - * if toggled_on flag is true then IJB is enabled, do the usual - * otherwise avoid crunching - */ - -/* This next line is a little ugly, but it simplifies the if statement below. */ -/* Basically if TOGGLE, then we want the if to test "csp->toggled_on", else we don't */ -#define IS_TOGGLED_ON csp->toggled_on && - -#else /* ifndef TOGGLE */ - -/* We don't have TOGGLE, so we don't care about toggling. */ -#define IS_TOGGLED_ON - -#endif /* ndef TOGGLE */ - - -#ifdef TRUST_FILES -/* This next line is a little ugly, but it simplifies the if statement below. */ -/* Basically if TRUST_FILES, then we want the if to call "trust_url", else we don't */ -#define IS_TRUSTED_URL (p = trust_url(http, csp)) || - -#else /* ifndef TRUST_FILES */ - -/* We don't have TRUST_FILES, so we don't care about trusted URL's. */ -#define IS_TRUSTED_URL - -#endif /* ndef TRUST_FILES */ + /* + * by haroon - most of credit to srt19170 + * if toggled_on flag is true then IJB is enabled, do the usual + * otherwise avoid crunching + */ /* Check the request against all rules, unless * we're disabled or in force mode. @@ -648,11 +648,9 @@ static void chat(struct client_state *csp) #ifdef KILLPOPUPS /* Filter the popups on this read. */ - if ( IS_TOGGLED_ON - ( kill_all_popups || - ( ( http->host != NULL ) && ( popupfile != NULL ) ) ) ) + if (block_popups_now) { - filter_popups(csp, http->host, buf, n); + filter_popups(buf, n); } #endif /* def KILLPOPUPS */ @@ -786,15 +784,25 @@ static void chat(struct client_state *csp) * the client (along with anything else that * may be in the buffer) */ - + +#ifdef KILLPOPUPS + /* Start blocking popups if appropriate. */ + + if (csp->is_text && /* It's a text / * MIME-Type */ + !http->ssl && /* We talk plaintext */ + block_popups) + { + block_popups_now = 1; + } + +#endif /* def KILLPOPUPS */ + #ifdef PCRS - /* Decide if we want to re_filter this. */ - - if (IS_TOGGLED_ON /* Only filter if toggle is "on" */ - csp->is_text && /* It's a text / * MIME-Type */ - re_filterfile && /* There are expressions to be used */ - !http->ssl && /* We talk plaintext */ - (re_filter_all || !csp->send_user_cookie)) /* Policy allows */ + /* Start re_filtering this if appropriate. */ + + if (csp->is_text && /* It's a text / * MIME-Type */ + !http->ssl && /* We talk plaintext */ + pcrs_filter) /* Policy allows */ { filtering = 1; } @@ -1114,8 +1122,8 @@ static void listen_loop(void) if (run_loader(csp)) { - log_error(LOG_LEVEL_ERROR, "a loader failed - must exit"); - return; + log_error(LOG_LEVEL_FATAL, "a loader failed - must exit"); + /* Never get here - LOG_LEVEL_FATAL causes program exit */ } if (multi_threaded) diff --git a/killpopup.c b/killpopup.c index 7004962d..53a193ed 100644 --- a/killpopup.c +++ b/killpopup.c @@ -1,7 +1,7 @@ -const char killpopup_rcs[] = "$Id: killpopup.c,v 1.1 2001/05/13 21:57:06 administrator Exp $"; +const char killpopup_rcs[] = "$Id: killpopup.c,v 1.1.1.1 2001/05/15 13:58:58 oes Exp $"; /********************************************************************* * - * File : $Source: /home/administrator/cvs/ijb/killpopup.c,v $ + * File : $Source: /cvsroot/ijbswa/current/killpopup.c,v $ * * Purpose : Handles the filtering of popups. * @@ -32,6 +32,9 @@ const char killpopup_rcs[] = "$Id: killpopup.c,v 1.1 2001/05/13 21:57:06 adminis * * Revisions : * $Log: killpopup.c,v $ + * Revision 1.1.1.1 2001/05/15 13:58:58 oes + * Initial import of version 2.9.3 source tree + * * *********************************************************************/ @@ -61,8 +64,6 @@ const char killpopup_h_rcs[] = KILLPOPUP_H_VERSION; /* Change these for debug output. *lots*. */ /*#define POPUP_VERBOSE 1*/ -/* CHANGED - added the below and shifted the more spammy stuff into it ;-) */ -#undef POPUP_VERY_VERBOSE #undef POPUP_VERBOSE @@ -71,102 +72,24 @@ const char killpopup_h_rcs[] = KILLPOPUP_H_VERSION; * Function : filter_popups * * Description : Filter the block of data that's been read from the server. - * IF NECESSARY. + * Caller is responsible for checking permissons list + * to determine if this function should be called. * * Parameters : - * 1 : csp = Client state - * 2 : host_name = hostname of originating web page to - * look up on blocklist - * 3 : buff = Buffer to scan and modify. Null terminated. - * 4 : size = Buffer size, excluding null terminator. + * 1 : buff = Buffer to scan and modify. Null terminated. + * 2 : size = Buffer size, excluding null terminator. * * Returns : void * *********************************************************************/ -void filter_popups(struct client_state *csp, char *host_name, char *buff, int size) +void filter_popups(char *buff, int size) { - struct popup_settings * data; - struct popup_blocklist * cur; - int i; - int found = 0; char *popup = NULL; char *close = NULL; char *p = NULL; char *q = NULL; /* by BREITENB NEW! */ - if ( (!csp->plist) || ((data = csp->plist->f) == NULL) ) - { - /* Disabled. */ - return; - } - - /* If the hostname is on our list for blocking then mark it - * as a host to block from. (This may be later changed if the - * host is also on the list-to-allow list). - */ - - for (i=0; (i < 50) && (i < size); i++) /* avoid scanning binary data! */ - { - if ((unsigned int)(buff[i])>127) - { -#ifdef POPUP_VERBOSE - fprintf(logfp, "I'm not scanning binary stuff! (%i)\n",buff[i]); -#endif - return; - } - } - - - for (cur = data->blocked ; cur ; cur = cur->next) - { - if ( host_name != 0 ) - { - if ( strcmp( cur->host_name, host_name ) == 0 ) - { -#ifdef POPUP_VERBOSE - fprintf(logfp, "Blocking %s\n", host_name ); -#endif - found = 1; - } - } - } - - /* Force match if we're supposed to nuke _all_ popups, globally. */ - if ( kill_all_popups != 0 ) - { -#ifdef POPUP_VERBOSE - fprintf(logfp, "Indescriminatly nuking popups..\n" ); -#endif - found = 1; - } - /* an exception-from blocking should still be an exception! by BREITENB NEW! */ - - - /* Now, if its allowed adjust the filtering, so it _doesn't_ happen. */ - for (cur = data->allowed ; cur ; cur = cur->next) - { - if ( host_name != 0 ) - { - if ( strcmp( cur->host_name, host_name ) == 0 ) - { -#ifdef POPUP_VERBOSE - fprintf(logfp, "Reversing block decision for %s\n", host_name ); -#endif - found = 0; - } - } - } - - if ( found == 0) - { -#ifdef POPUP_VERBOSE - fprintf(logfp, "Allowing %s\n", host_name ); -#endif - return; - } - while ((popup = strstr( buff, "window.open(" )) != NULL) - /* if ( popup ) by BREITENB filter ALL popups! NEW! */ { #ifdef POPUP_VERBOSE fprintf(logfp, "Found start of window open" ); @@ -217,8 +140,8 @@ void filter_popups(struct client_state *csp, char *host_name, char *buff, int si if (!popup) popup=strstr( buff, "'); - if (q) + close=strchr(popup,'>'); + if (close) { /* we are now between */ p=strstr(popup, "onUnload"); diff --git a/killpopup.h b/killpopup.h index 42602ea2..23bd7d7b 100644 --- a/killpopup.h +++ b/killpopup.h @@ -1,9 +1,9 @@ #ifndef _KILLPOPUP_H #define _KILLPOPUP_H -#define KILLPOPUP_H_VERSION "$Id: killpopup.h,v 1.1 2001/05/13 21:57:06 administrator Exp $" +#define KILLPOPUP_H_VERSION "$Id: killpopup.h,v 1.1.1.1 2001/05/15 13:58:58 oes Exp $" /********************************************************************* * - * File : $Source: /home/administrator/cvs/ijb/killpopup.h,v $ + * File : $Source: /cvsroot/ijbswa/current/killpopup.h,v $ * * Purpose : Handles the filtering of popups. * @@ -34,6 +34,9 @@ * * Revisions : * $Log: killpopup.h,v $ + * Revision 1.1.1.1 2001/05/15 13:58:58 oes + * Initial import of version 2.9.3 source tree + * * *********************************************************************/ @@ -42,7 +45,7 @@ #ifdef KILLPOPUPS -extern void filter_popups(struct client_state *csp, char *host_name, char *buff, int size); +extern void filter_popups(char *buff, int size); #endif /* def KILLPOPUPS */ diff --git a/loadcfg.c b/loadcfg.c index d58e9616..185241be 100644 --- a/loadcfg.c +++ b/loadcfg.c @@ -1,4 +1,4 @@ -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.2 2001/05/17 23:01:01 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $ @@ -35,6 +35,9 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.1.1.1 2001/05/15 13:58:58 oes Exp * * Revisions : * $Log: loadcfg.c,v $ + * 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 * @@ -130,7 +133,7 @@ const char *logfile = NULL; const char *configfile = NULL; const char *blockfile = NULL; -const char *cookiefile = NULL; +const char *permissions_file = NULL; const char *forwardfile = NULL; #ifdef ACL_FILES @@ -140,15 +143,14 @@ const char *aclfile = NULL; #ifdef USE_IMAGE_LIST 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 TRUST_FILES @@ -169,7 +171,7 @@ const char *suppress_message = NULL; #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]; @@ -210,7 +212,8 @@ const char **Argv = NULL; * 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 @@ -222,7 +225,7 @@ const char **Argv = NULL; #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 @@ -230,10 +233,7 @@ const char **Argv = NULL; #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 @@ -267,7 +267,7 @@ const char **Argv = NULL; * Returns : configret : 0 => Ok, everything else is an error. * Note: we use configret since a signal handler cannot * return a value, and this function does double duty. - * Ie. Is is called from main and from signal( SIGHUP ); + * Ie. Is is called from main and from signal( SIGHUP ); * *********************************************************************/ void load_config( int signum ) @@ -276,7 +276,7 @@ void load_config( int signum ) 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); @@ -285,9 +285,9 @@ void load_config( int signum ) /* (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. */ @@ -300,16 +300,18 @@ void load_config( int signum ) * 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; + multi_threaded = 1; + + default_permissions = PERMIT_RE_FILTER; #if defined(DETECT_MSIE_IMAGES) || defined(USE_IMAGE_LIST) tinygif = 0; @@ -324,14 +326,6 @@ void load_config( int signum ) 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 @@ -353,7 +347,7 @@ void load_config( int signum ) freez((char *)blockfile); - freez((char *)cookiefile); + freez((char *)permissions_file); freez((char *)forwardfile); #ifdef ACL_FILES @@ -368,10 +362,6 @@ void load_config( int signum ) 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 */ @@ -388,10 +378,9 @@ void load_config( int signum ) { 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 */ } } @@ -515,9 +504,9 @@ void load_config( int signum ) 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 : @@ -561,28 +550,11 @@ void load_config( int signum ) 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 : @@ -682,7 +654,6 @@ void load_config( int signum ) #endif /* ndef USE_IMAGE_LIST */ #ifndef PCRS case hash_re_filterfile : - case hash_re_filter_all : #endif /* ndef PCRS */ #ifndef TOGGLE case hash_toggle : @@ -704,10 +675,6 @@ void load_config( int signum ) #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 */ @@ -722,6 +689,11 @@ void load_config( int signum ) 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 ); @@ -731,15 +703,6 @@ void load_config( int signum ) 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; } } @@ -748,9 +711,9 @@ void load_config( int signum ) init_error_log(Argv[0], logfile, debug); - if (cookiefile) + if (permissions_file) { - add_loader(load_cookiefile); + add_loader(load_permissions_file); } if (blockfile) @@ -784,13 +747,6 @@ void load_config( int signum ) } #endif /* def ACL_FILES */ -#ifdef KILLPOPUPS - if (popupfile) - { - add_loader(load_popupfile); - } -#endif /* def KILLPOPUPS */ - #ifdef PCRS if (re_filterfile) { @@ -803,9 +759,8 @@ void load_config( int signum ) { 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); } @@ -830,9 +785,8 @@ void load_config( int signum ) 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') { @@ -842,8 +796,8 @@ void load_config( int signum ) 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 diff --git a/loadcfg.h b/loadcfg.h index 941fa41a..58ed1bbb 100644 --- a/loadcfg.h +++ b/loadcfg.h @@ -1,6 +1,6 @@ #ifndef _LOADCFG_H #define _LOADCFG_H -#define LOADCFG_H_VERSION "$Id: loadcfg.h,v 1.1.1.1 2001/05/15 13:58:58 oes Exp $" +#define LOADCFG_H_VERSION "$Id: loadcfg.h,v 1.2 2001/05/17 23:01:01 oes Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loadcfg.h,v $ @@ -37,6 +37,9 @@ * * Revisions : * $Log: loadcfg.h,v $ + * 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 * @@ -78,17 +81,13 @@ extern const char *aclfile; #endif /* def ACL_FILES */ extern const char *blockfile; -extern const char *cookiefile; +extern const char *permissions_file; extern const char *forwardfile; #ifdef USE_IMAGE_LIST extern const char *imagefile; #endif /* def USE_IMAGE_LIST */ -#ifdef KILLPOPUPS -extern const char *popupfile; -#endif /* def KILLPOPUPS */ - #ifdef TRUST_FILES extern const char *trustfile; #endif /* def TRUST_FILES */ @@ -97,13 +96,7 @@ extern const char *trustfile; extern const char *re_filterfile; #endif /* def PCRS */ -#ifdef PCRS -extern int re_filter_all; -#endif /* def PCRS */ - -#ifdef KILLPOPUPS -extern int kill_all_popups; /* Not recommended really .. */ -#endif /* def KILLPOPUPS */ +extern int default_permissions; #ifdef JAR_FILES extern const char *jarfile; @@ -138,7 +131,7 @@ extern int suppress_blocklists; /* suppress listing sblock and simage */ extern struct proxy_args proxy_args[1]; -extern int configret; +extern int configret; /* FIXME: This is obsolete, always 0. */ extern int config_changed; diff --git a/loaders.c b/loaders.c index f3ea5a13..5767ee2e 100644 --- a/loaders.c +++ b/loaders.c @@ -1,4 +1,4 @@ -const char loaders_rcs[] = "$Id: loaders.c,v 1.1.1.1 2001/05/15 13:58:59 oes Exp $"; +const char loaders_rcs[] = "$Id: loaders.c,v 1.2 2001/05/17 23:01:01 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loaders.c,v $ @@ -35,6 +35,9 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.1.1.1 2001/05/15 13:58:59 oes Exp * * Revisions : * $Log: loaders.c,v $ + * 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:59 oes * Initial import of version 2.9.3 source tree * @@ -87,14 +90,14 @@ const char loaders_h_rcs[] = LOADERS_H_VERSION; #define NLOADERS 8 static int (*loaders[NLOADERS])(struct client_state *); - - + + /* * Currently active files. * These are also entered in the main linked list of files. */ static struct file_list *current_blockfile = NULL; -static struct file_list *current_cookiefile = NULL; +static struct file_list *current_permissions_file = NULL; static struct file_list *current_forwardfile = NULL; #ifdef ACL_FILES @@ -105,10 +108,6 @@ static struct file_list *current_aclfile = NULL; static struct file_list *current_imagefile = NULL; #endif /* def USE_IMAGE_LIST */ -#ifdef KILLPOPUPS -static struct file_list * current_popupfile = NULL; -#endif /* def KILLPOPUPS */ - #ifdef TRUST_FILES static struct file_list *current_trustfile = NULL; #endif /* def TRUST_FILES */ @@ -116,7 +115,10 @@ static struct file_list *current_trustfile = NULL; #ifdef PCRS static struct file_list *current_re_filterfile = NULL; #endif /* def PCRS */ - + + +static int create_url_spec(struct url_spec * url, char * buf); + /********************************************************************* * @@ -164,12 +166,11 @@ void sweep(void) ncsp->blist->active = 1; } - if (ncsp->clist) /* cookie files */ + if (ncsp->permissions_list) /* permissions files */ { - ncsp->clist->active = 1; + ncsp->permissions_list->active = 1; } - /* FIXME: These were left out of the "10" release. Should they be here? */ if (ncsp->flist) /* forward files */ { ncsp->flist->active = 1; @@ -189,13 +190,6 @@ void sweep(void) } #endif /* def USE_IMAGE_LIST */ -#ifdef KILLPOPUPS - if (ncsp->plist) /* killpopup files */ - { - ncsp->plist->active = 1; - } -#endif /* def KILLPOPUPS */ - #ifdef PCRS if (ncsp->rlist) /* perl re files */ { @@ -260,6 +254,125 @@ void sweep(void) } +/********************************************************************* + * + * Function : create_url_spec + * + * Description : Creates a "url_spec" structure from a string. + * When finished, free with unload_url(). + * + * Parameters : + * 1 : url = Target url_spec to be filled in. Must be + * zeroed out before the call (e.g. using zalloc). + * 2 : buf = Source pattern, null terminated. NOTE: The + * contents of this buffer are destroyed by this + * function. If this function succeeds, the + * buffer is copied to url->spec. If this + * function fails, the contents of the buffer + * are lost forever. + * + * Returns : 0 => Ok, everything else is an error. + * + *********************************************************************/ +static int create_url_spec(struct url_spec * url, char * buf) +{ + char *p; + struct url_spec tmp_url[1]; + + /* paranoia - should never happen. */ + if ((url == NULL) || (buf == NULL)) + { + return 1; + } + + /* save a copy of the orignal specification */ + if ((url->spec = strdup(buf)) == NULL) + { + return 1; + } + + if ((p = strchr(buf, '/'))) + { + if (NULL == (url->path = strdup(p))) + { + freez(url->spec); + return 1; + } + url->pathlen = strlen(url->path); + *p = '\0'; + } + else + { + url->path = NULL; + url->pathlen = 0; + } +#ifdef REGEX + if (url->path) + { + int errcode; + char rebuf[BUFSIZ]; + + if (NULL == (url->preg = zalloc(sizeof(*url->preg)))) + { + freez(url->spec); + freez(url->path); + return 1; + } + + sprintf(rebuf, "^(%s)", url->path); + + errcode = regcomp(url->preg, rebuf, + (REG_EXTENDED|REG_NOSUB|REG_ICASE)); + if (errcode) + { + size_t errlen = + regerror(errcode, + url->preg, buf, sizeof(buf)); + + buf[errlen] = '\0'; + + log_error(LOG_LEVEL_ERROR, "error compiling %s: %s", + url->spec, buf); + + freez(url->spec); + freez(url->path); + freez(url->preg); + + return 1; + } + } +#endif + if ((p = strchr(buf, ':')) == NULL) + { + url->port = 0; + } + else + { + *p++ = '\0'; + url->port = atoi(p); + } + + if ((url->domain = strdup(buf)) == NULL) + { + freez(url->spec); + freez(url->path); +#ifdef REGEX + freez(url->preg); +#endif /* def REGEX */ + return 1; + } + + /* split domain into components */ + + *tmp_url = dsplit(url->domain); + url->dbuf = tmp_url->dbuf; + url->dcnt = tmp_url->dcnt; + url->dvec = tmp_url->dvec; + + return 0; /* OK */ +} + + /********************************************************************* * * Function : unload_url @@ -374,26 +487,28 @@ static void unload_imagefile(void *f) /********************************************************************* * - * Function : unload_cookiefile + * Function : unload_permissions_file * - * Description : Unloads a cookiefile. + * Description : Unloads a permissions file. * * Parameters : - * 1 : f = the data structure associated with the cookiefile. + * 1 : file_data = the data structure associated with the + * permissions file. * * Returns : N/A * *********************************************************************/ -static void unload_cookiefile(void *f) -{ - struct cookie_spec *b = (struct cookie_spec *)f; - if (b == NULL) return; - - unload_cookiefile(b->next); - - unload_url(b->url); - - freez(b); +static void unload_permissions_file(void *file_data) +{ + struct permissions_spec * next; + struct permissions_spec * cur = (struct permissions_spec *)file_data; + while (cur != NULL) + { + next = cur->next; + unload_url(cur->url); + freez(cur); + cur = next; + } } @@ -486,51 +601,6 @@ static void unload_re_filterfile(void *f) #endif /* def PCRS */ -#ifdef KILLPOPUPS -/********************************************************************* - * - * Function : unload_popupfile - * - * Description : Free the lists of blocked, and allowed popup sites. - * - * Parameters : - * 1 : csp = Current client state (buffers, headers, etc...) - * - * Returns : N/A - * - *********************************************************************/ -static void unload_popupfile(void * b) -{ - struct popup_settings * data = (struct popup_settings *) b; - struct popup_blocklist * cur = NULL; - struct popup_blocklist * temp= NULL; - - /* Free the blocked list. */ - cur = data->blocked; - while (cur != NULL) - { - temp = cur->next; - freez (cur->host_name); - free (cur); - cur = temp; - } - data->blocked = NULL; - - /* Free the allowed list. */ - cur = data->allowed; - while (cur != NULL) - { - temp = cur->next; - freez (cur->host_name); - free (cur); - cur = temp; - } - data->allowed = NULL; - -} -#endif /* def KILLPOPUPS */ - - /********************************************************************* * * Function : check_file_changed @@ -552,7 +622,7 @@ static void unload_popupfile(void * b) * heap, with the filename and lastmodified * fields filled, standard header giving file * name in proxy_args, and all others zeroed. - * (proxy_args is only filled in if + * (proxy_args is only filled in if !defined * SPLIT_PROXY_ARGS and !suppress_blocklists). * * Returns : If file unchanged: 0 (and sets newfl == NULL) @@ -692,8 +762,8 @@ char *read_config_line(char *buf, int buflen, FILE *fp, struct file_list *fs) p = linebuf + strlen(linebuf) - 1; /* - * Note: the (p >= retval) below is paranoia, it's not really needed. - * When p == retval then ijb_isspace(*p) will be false and we'll drop + * Note: the (p >= linebuf) below is paranoia, it's not really needed. + * When p == linebuf then ijb_isspace(*p) will be false and we'll drop * out of the loop. */ while ((p >= linebuf) && ijb_isspace(*p)) @@ -871,9 +941,8 @@ int load_blockfile(struct client_state *csp) struct block_spec *b, *bl; char buf[BUFSIZ], *p, *q; - int port, reject; + int reject; struct file_list *fs; - struct url_spec url[1]; if (!check_file_changed(current_blockfile, blockfile, &fs)) { @@ -922,11 +991,7 @@ int load_blockfile(struct client_state *csp) } /* allocate a new node */ - if (((b = zalloc(sizeof(*b))) == NULL) -#ifdef REGEX - || ((b->url->preg = zalloc(sizeof(*b->url->preg))) == NULL) -#endif - ) + if ((b = zalloc(sizeof(*b))) == NULL) { fclose(fp); goto load_blockfile_error; @@ -936,79 +1001,14 @@ int load_blockfile(struct client_state *csp) b->next = bl->next; bl->next = b; - /* save a copy of the orignal specification */ - if ((b->url->spec = strdup(buf)) == NULL) - { - fclose(fp); - goto load_blockfile_error; - } - b->reject = reject; - - if ((p = strchr(buf, '/'))) - { - b->url->path = strdup(p); - b->url->pathlen = strlen(b->url->path); - *p = '\0'; - } - else - { - b->url->path = NULL; - b->url->pathlen = 0; - } -#ifdef REGEX - if (b->url->path) - { - int errcode; - char rebuf[BUFSIZ]; - - sprintf(rebuf, "^(%s)", b->url->path); - - errcode = regcomp(b->url->preg, rebuf, - (REG_EXTENDED|REG_NOSUB|REG_ICASE)); - - if (errcode) - { - size_t errlen = - regerror(errcode, - b->url->preg, buf, sizeof(buf)); - - buf[errlen] = '\0'; - - log_error(LOG_LEVEL_ERROR, "error compiling %s: %s\n", - b->url->spec, buf); - fclose(fp); - goto load_blockfile_error; - } - } - else - { - freez(b->url->preg); - } -#endif - if ((p = strchr(buf, ':')) == NULL) - { - port = 0; - } - else - { - *p++ = '\0'; - port = atoi(p); - } - - b->url->port = port; - - if ((b->url->domain = strdup(buf)) == NULL) - { - fclose(fp); - goto load_blockfile_error; - } - - /* split domain into components */ - *url = dsplit(b->url->domain); - b->url->dbuf = url->dbuf; - b->url->dcnt = url->dcnt; - b->url->dvec = url->dvec; + + /* Save the URL pattern */ + if (create_url_spec(b->url, buf)) + { + fclose(fp); + goto load_blockfile_error; + } } fclose(fp); @@ -1063,9 +1063,8 @@ int load_imagefile(struct client_state *csp) struct block_spec *b, *bl; char buf[BUFSIZ], *p, *q; - int port, reject; + int reject; struct file_list *fs; - struct url_spec url[1]; if (!check_file_changed(current_imagefile, imagefile, &fs)) { @@ -1114,11 +1113,7 @@ int load_imagefile(struct client_state *csp) } /* allocate a new node */ - if (((b = zalloc(sizeof(*b))) == NULL) -#ifdef REGEX - || ((b->url->preg = zalloc(sizeof(*b->url->preg))) == NULL) -#endif - ) + if ((b = zalloc(sizeof(*b))) == NULL) { fclose(fp); goto load_imagefile_error; @@ -1127,86 +1122,17 @@ int load_imagefile(struct client_state *csp) /* add it to the list */ b->next = bl->next; bl->next = b; + + b->reject = reject; - /* save a copy of the orignal specification */ - if ((b->url->spec = strdup(buf)) == NULL) + /* Save the URL pattern */ + if (create_url_spec(b->url, buf)) { fclose(fp); goto load_imagefile_error; } - - b->reject = reject; - - if ((p = strchr(buf, '/'))) - { - b->url->path = strdup(p); - b->url->pathlen = strlen(b->url->path); - *p = '\0'; - } - else - { - b->url->path = NULL; - b->url->pathlen = 0; - } -#ifdef REGEX - if (b->url->path) - { - int errcode; - char rebuf[BUFSIZ]; - - sprintf(rebuf, "^(%s)", b->url->path); - - errcode = regcomp(b->url->preg, rebuf, - (REG_EXTENDED|REG_NOSUB|REG_ICASE)); - - if (errcode) - { - size_t errlen = - regerror(errcode, - b->url->preg, buf, sizeof(buf)); - - buf[errlen] = '\0'; - - log_error(LOG_LEVEL_ERROR, "error compiling %s: %s", - b->url->spec, buf); - fclose(fp); - goto load_imagefile_error; - } - } - else - { - freez(b->url->preg); - } -#endif - if ((p = strchr(buf, ':')) == NULL) - { - port = 0; - } - else - { - *p++ = '\0'; - port = atoi(p); - } - - b->url->port = port; - - if ((b->url->domain = strdup(buf)) == NULL) - { - fclose(fp); - goto load_imagefile_error; - } - - /* split domain into components */ - *url = dsplit(b->url->domain); - b->url->dbuf = url->dbuf; - b->url->dcnt = url->dcnt; - b->url->dvec = url->dvec; } -#ifndef SPLIT_PROXY_ARGS - if (!suppress_blocklists) - fs->proxy_args = strsav(fs->proxy_args, ""); -#endif /* ndef SPLIT_PROXY_ARGS */ - + fclose(fp); #ifndef SPLIT_PROXY_ARGS @@ -1240,12 +1166,13 @@ load_imagefile_error: } #endif /* def USE_IMAGE_LIST */ - + /********************************************************************* * - * Function : load_cookiefile + * Function : load_permissions_file * - * Description : Read and parse a cookiefile and add to files list. + * Description : Read and parse a permissions file and add to files + * list. * * Parameters : * 1 : csp = Current client state (buffers, headers, etc...) @@ -1253,69 +1180,112 @@ load_imagefile_error: * Returns : 0 => Ok, everything else is an error. * *********************************************************************/ -int load_cookiefile(struct client_state *csp) +int load_permissions_file(struct client_state *csp) { FILE *fp; - struct cookie_spec *b, *bl; + struct permissions_spec *b, *bl; char buf[BUFSIZ], *p, *q; - int port, user_cookie, server_cookie; - struct file_list *fs; - struct url_spec url[1]; + int permissions; + struct file_list *fs; + int i; - if (!check_file_changed(current_cookiefile, cookiefile, &fs)) + if (!check_file_changed(current_permissions_file, permissions_file, &fs)) { /* No need to load */ if (csp) { - csp->clist = current_cookiefile; + csp->permissions_list = current_permissions_file; } return(0); } if (!fs) { - goto load_cookie_error; + goto load_permissions_error; } - fs->f = bl = (struct cookie_spec *)zalloc(sizeof(*bl)); + fs->f = bl = (struct permissions_spec *)zalloc(sizeof(*bl)); if (bl == NULL) { - goto load_cookie_error; + goto load_permissions_error; } - if ((fp = fopen(cookiefile, "r")) == NULL) + if ((fp = fopen(permissions_file, "r")) == NULL) { - goto load_cookie_error; - } + goto load_permissions_error; + } + + + /* + * default_permissions is set in this file. + * + * Reset it to default first. + */ + default_permissions = PERMIT_RE_FILTER; while (read_config_line(buf, sizeof(buf), fp, fs) != NULL) { - p = buf; - - switch ((int)*p) - { - case '>': - server_cookie = 0; - user_cookie = 1; - p++; - break; + p = buf; + + permissions = PERMIT_COOKIE_SET | PERMIT_COOKIE_READ | PERMIT_POPUPS; + + /* + * FIXME: for() loop is a kludge. Want to loop around until we + * find a non-control character. Assume there will be at most 4 + * characters. + */ + for (i = 0; i < 4; i++) + { + switch ((int)*p) + { + case '>': + /* + * Allow cookies to be read by the server, but do + * not allow them to be set. + */ + permissions = (permissions & ~PERMIT_COOKIE_SET); + p++; + break; - case '<': - server_cookie = 1; - user_cookie = 0; - p++; - break; + case '<': + /* + * Allow server to set cookies but do not let the + * server read them. + */ + permissions = (permissions & ~PERMIT_COOKIE_READ); + p++; + break; - case '~': - server_cookie = 0; - user_cookie = 0; - p++; - break; + case '^': + /* + * Block popups + */ + permissions = (permissions & ~PERMIT_POPUPS); + p++; + break; + + case '%': + /* + * Permit filtering using PCRS + */ + permissions = (permissions | PERMIT_RE_FILTER); + p++; + break; + + case '~': + /* + * All of the above (maximum filtering). + */ + permissions = PERMIT_RE_FILTER; + p++; + break; - default: - server_cookie = 1; - user_cookie = 1; - break; + default: + /* + * FIXME: Should break out of the loop here. + */ + break; + } } /* @@ -1323,106 +1293,42 @@ int load_cookiefile(struct client_state *csp) * front of the pattern */ q = buf; - if (p > q) while ((*q++ = *p++)) - { - /* nop */ + if (p > q) + { + while ((*q++ = *p++) != '\0') + { + /* nop */ + } } - /* skip lines containing only "special" chars */ + /* a lines containing only "special" chars sets default */ if (*buf == '\0') - { + { + default_permissions = permissions; continue; } /* allocate a new node */ if (((b = zalloc(sizeof(*b))) == NULL) -#ifdef REGEX - || ((b->url->preg = zalloc(sizeof(*b->url->preg))) == NULL) -#endif ) { fclose(fp); - goto load_cookie_error; + goto load_permissions_error; } /* add it to the list */ b->next = bl->next; bl->next = b; - - /* save a copy of the orignal specification */ - if ((b->url->spec = strdup(buf)) == NULL) - { - fclose(fp); - goto load_cookie_error; - } - - b->send_user_cookie = user_cookie; - b->accept_server_cookie = server_cookie; - - if ((p = strchr(buf, '/'))) - { - b->url->path = strdup(p); - b->url->pathlen = strlen(b->url->path); - *p = '\0'; - } - else - { - b->url->path = NULL; - b->url->pathlen = 0; - } -#ifdef REGEX - if (b->url->path) - { - int errcode; - char rebuf[BUFSIZ]; - - sprintf(rebuf, "^(%s)", b->url->path); - - errcode = regcomp(b->url->preg, rebuf, - (REG_EXTENDED|REG_NOSUB|REG_ICASE)); - if (errcode) - { - size_t errlen = - regerror(errcode, - b->url->preg, buf, sizeof(buf)); - - buf[errlen] = '\0'; - - log_error(LOG_LEVEL_ERROR, "error compiling %s: %s", - b->url->spec, buf); - fclose(fp); - goto load_cookie_error; - } - } - else - { - freez(b->url->preg); - } -#endif - if ((p = strchr(buf, ':')) == NULL) - { - port = 0; - } - else - { - *p++ = '\0'; - port = atoi(p); - } - - b->url->port = port; - - if ((b->url->domain = strdup(buf)) == NULL) - { + + /* Save flags */ + b->permissions = permissions; + + /* Save the URL pattern */ + if (create_url_spec(b->url, buf)) + { fclose(fp); - goto load_cookie_error; + goto load_permissions_error; } - - /* split domain into components */ - - *url = dsplit(b->url->domain); - b->url->dbuf = url->dbuf; - b->url->dcnt = url->dcnt; - b->url->dvec = url->dvec; } fclose(fp); @@ -1435,24 +1341,24 @@ int load_cookiefile(struct client_state *csp) #endif /* ndef SPLIT_PROXY_ARGS */ /* the old one is now obsolete */ - if (current_cookiefile) + if (current_permissions_file) { - current_cookiefile->unloader = unload_cookiefile; + current_permissions_file->unloader = unload_permissions_file; } fs->next = files->next; files->next = fs; - current_cookiefile = fs; + current_permissions_file = fs; if (csp) { - csp->clist = fs; + csp->permissions_list = fs; } return(0); -load_cookie_error: - log_error(LOG_LEVEL_ERROR, "can't load cookiefile '%s': %E", cookiefile); +load_permissions_error: + log_error(LOG_LEVEL_ERROR, "can't load permissions file '%s': %E", permissions_file); return(-1); } @@ -1479,9 +1385,8 @@ int load_trustfile(struct client_state *csp) struct url_spec **tl; char buf[BUFSIZ], *p, *q; - int port, reject, trusted; + int reject, trusted; struct file_list *fs; - struct url_spec url[1]; if (!check_file_changed(current_trustfile, trustfile, &fs)) { @@ -1539,11 +1444,7 @@ int load_trustfile(struct client_state *csp) } /* allocate a new node */ - if (((b = zalloc(sizeof(*b))) == NULL) -#ifdef REGEX - || ((b->url->preg = zalloc(sizeof(*b->url->preg))) == NULL) -#endif - ) + if ((b = zalloc(sizeof(*b))) == NULL) { fclose(fp); goto load_trustfile_error; @@ -1553,80 +1454,15 @@ int load_trustfile(struct client_state *csp) b->next = bl->next; bl->next = b; - /* save a copy of the orignal specification */ - if ((b->url->spec = strdup(buf)) == NULL) - { - fclose(fp); - goto load_trustfile_error; - } - b->reject = reject; - if ((p = strchr(buf, '/'))) - { - b->url->path = strdup(p); - b->url->pathlen = strlen(b->url->path); - *p = '\0'; - } - else - { - b->url->path = NULL; - b->url->pathlen = 0; - } -#ifdef REGEX - if (b->url->path) - { - int errcode; - char rebuf[BUFSIZ]; - - sprintf(rebuf, "^(%s)", b->url->path); - - errcode = regcomp(b->url->preg, rebuf, - (REG_EXTENDED|REG_NOSUB|REG_ICASE)); - - if (errcode) - { - size_t errlen = - regerror(errcode, - b->url->preg, buf, sizeof(buf)); - - buf[errlen] = '\0'; - - log_error(LOG_LEVEL_ERROR, "error compiling %s: %s", - b->url->spec, buf); - fclose(fp); - goto load_trustfile_error; - } - } - else - { - freez(b->url->preg); - } -#endif - if ((p = strchr(buf, ':')) == NULL) - { - port = 0; - } - else - { - *p++ = '\0'; - port = atoi(p); - } - - b->url->port = port; - - if ((b->url->domain = strdup(buf)) == NULL) + /* Save the URL pattern */ + if (create_url_spec(b->url, buf)) { fclose(fp); goto load_trustfile_error; } - /* split domain into components */ - *url = dsplit(b->url->domain); - b->url->dbuf = url->dbuf; - b->url->dcnt = url->dcnt; - b->url->dvec = url->dvec; - /* * save a pointer to URL's spec in the list of trusted URL's, too */ @@ -1966,9 +1802,6 @@ int load_re_filterfile(struct client_state *csp) int error; pcrs_job *dummy; -#ifndef SPLIT_PROXY_ARGS - char *p; -#endif /* ndef SPLIT_PROXY_ARGS */ if (!check_file_changed(current_re_filterfile, re_filterfile, &fs)) { /* No need to load */ @@ -2003,7 +1836,7 @@ int load_re_filterfile(struct client_state *csp) /* We have a meaningful line -> make it a job */ if ((dummy = pcrs_make_job(buf, &error)) == NULL) { - log_error(LOG_LEVEL_REF, + log_error(LOG_LEVEL_RE_FILTER, "Adding re_filter job %s failed with error %d.", buf, error); continue; } @@ -2011,7 +1844,7 @@ int load_re_filterfile(struct client_state *csp) { dummy->next = bl->joblist; bl->joblist = dummy; - log_error(LOG_LEVEL_REF, "Adding re_filter job %s succeeded.", buf); + log_error(LOG_LEVEL_RE_FILTER, "Adding re_filter job %s succeeded.", buf); } } @@ -2049,127 +1882,6 @@ load_re_filterfile_error: #endif /* def PCRS */ -#ifdef KILLPOPUPS -/********************************************************************* - * - * Function : load_popupfile - * - * Description : Load, and parse the popup blocklist. - * - * Parameters : - * 1 : csp = Current client state (buffers, headers, etc...) - * - * Returns : 0 => success, else there was an error. - * - *********************************************************************/ -int load_popupfile(struct client_state *csp) -{ - FILE *fp; - char buf[BUFSIZ], *p, *q; - struct popup_blocklist *entry = NULL; - struct popup_settings * data; - struct file_list *fs; - p = buf; - q = buf; - - if (!check_file_changed(current_popupfile, popupfile, &fs)) - { - /* No need to load */ - if (csp) - { - csp->plist = current_popupfile; - } - return(0); - } - if (!fs) - { - goto load_popupfile_error; - } - - fs->f = data = (struct popup_settings *)zalloc(sizeof(*data)); - if (data == NULL) - { - goto load_popupfile_error; - } - - if ((fp = fopen(popupfile, "r")) == NULL) - { - goto load_popupfile_error; - } - - while (read_config_line(buf, sizeof(buf), fp, fs) != NULL) - { - entry = (struct popup_blocklist*)zalloc(sizeof(struct popup_blocklist)); - if (!entry) - { - fclose( fp ); - goto load_popupfile_error; - } - - /* Handle allowed hosts. */ - if ( *buf == '~' ) - { - /* Rememeber: skip the tilde */ - entry->host_name = strdup( buf + 1 ); - if (!entry->host_name) - { - fclose( fp ); - goto load_popupfile_error; - } - - entry->next = data->allowed; - data->allowed = entry; - } - else - { - /* Blocked host */ - entry->host_name = strdup( buf ); - if (!entry->host_name) - { - fclose( fp ); - goto load_popupfile_error; - } - - entry->next = data->blocked; - data->blocked = entry; - } - } - - fclose( fp ); - -#ifndef SPLIT_PROXY_ARGS - if (!suppress_blocklists) - { - fs->proxy_args = strsav(fs->proxy_args, ""); - } -#endif /* ndef SPLIT_PROXY_ARGS */ - - /* the old one is now obsolete */ - if ( NULL != current_popupfile ) - { - current_popupfile->unloader = unload_popupfile; - } - - fs->next = files->next; - files->next = fs; - current_popupfile = fs; - - if (csp) - { - csp->plist = fs; - } - - return( 0 ); - -load_popupfile_error: - log_error(LOG_LEVEL_ERROR, "can't load popupfile '%s': %E", popupfile); - return(-1); - -} -#endif /* def KILLPOPUPS */ - - - /********************************************************************* * * Function : add_loader diff --git a/loaders.h b/loaders.h index 0551a6e9..35e9ecbc 100644 --- a/loaders.h +++ b/loaders.h @@ -1,9 +1,9 @@ #ifndef _LOADERS_H #define _LOADERS_H -#define LOADERS_H_VERSION "$Id: loaders.h,v 1.1 2001/05/13 21:57:06 administrator Exp $" +#define LOADERS_H_VERSION "$Id: loaders.h,v 1.1.1.1 2001/05/15 13:59:00 oes Exp $" /********************************************************************* * - * File : $Source: /home/administrator/cvs/ijb/loaders.h,v $ + * File : $Source: /cvsroot/ijbswa/current/loaders.h,v $ * * Purpose : Functions to load and unload the various * configuration files. Also contains code to manage @@ -37,6 +37,9 @@ * * Revisions : * $Log: loaders.h,v $ + * Revision 1.1.1.1 2001/05/15 13:59:00 oes + * Initial import of version 2.9.3 source tree + * * *********************************************************************/ @@ -51,7 +54,7 @@ extern void sweep(void); extern char *read_config_line(char *buf, int buflen, FILE *fp, struct file_list *fs); extern int load_blockfile(struct client_state *csp); -extern int load_cookiefile(struct client_state *csp); +extern int load_permissions_file(struct client_state *csp); extern int load_forwardfile(struct client_state *csp); #ifdef ACL_FILES @@ -62,10 +65,6 @@ extern int load_aclfile(struct client_state *csp); extern int load_imagefile(struct client_state *csp); #endif /* def USE_IMAGE_LIST */ -#ifdef KILLPOPUPS -extern int load_popupfile(struct client_state *csp); -#endif /* def KILLPOPUPS */ - #ifdef TRUST_FILES extern int load_trustfile(struct client_state *csp); #endif /* def TRUST_FILES */ @@ -82,10 +81,6 @@ extern void remove_all_loaders(void); extern int load_re_filterfile(struct client_state *csp); #endif /* def PCRS */ -#ifdef KILLPOPUPS -extern int load_popupfile(struct client_state *csp); -#endif /* def KILLPOPUPS */ - /* Revision control strings from this header and associated .c file */ extern const char loaders_rcs[]; extern const char loaders_h_rcs[]; diff --git a/parsers.c b/parsers.c index ae6c1f46..ad686b3b 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.1.1.1 2001/05/15 13:59:01 oes Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.2 2001/05/17 23:02:36 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -41,6 +41,9 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.1.1.1 2001/05/15 13:59:01 oes Exp * * Revisions : * $Log: parsers.c,v $ + * Revision 1.2 2001/05/17 23:02:36 oes + * - Made referrer option accept 'L' as a substitute for '§' + * * Revision 1.1.1.1 2001/05/15 13:59:01 oes * Initial import of version 2.9.3 source tree * @@ -120,10 +123,10 @@ const struct interceptors intercept_patterns[] = { const struct parsers server_patterns[] = { { "set-cookie:", 11, server_set_cookie }, { "connection:", 11, crumble }, -#ifdef PCRS +#if defined(PCRS) || defined(KILLPOPUPS) { "Content-Type:", 13, content_type }, { "Content-Length:", 15, crumble }, -#endif /* def PCRS */ +#endif /* defined(PCRS) || defined(KILLPOPUPS) */ { NULL, 0, NULL } }; @@ -707,7 +710,7 @@ char *crumble(const struct parsers *v, char *s, struct client_state *csp) } -#ifdef PCRS +#if defined(PCRS) || defined(KILLPOPUPS) /********************************************************************* * @@ -734,7 +737,7 @@ char *content_type(const struct parsers *v, char *s, struct client_state *csp) } -#endif /* def PCRS */ +#endif /* defined(PCRS) || defined(KILLPOPUPS) */ /********************************************************************* @@ -778,7 +781,7 @@ char *client_referrer(const struct parsers *v, char *s, struct client_state *csp if (*referrer == '@') { - if (csp->send_user_cookie) + if (csp->permissions & PERMIT_COOKIE_READ) { return(strdup(s)); } @@ -796,7 +799,7 @@ char *client_referrer(const struct parsers *v, char *s, struct client_state *csp if (*referrer == '§' || *referrer == 'L') { - if (csp->send_user_cookie) + if (csp->permissions & PERMIT_COOKIE_READ) { return(strdup(s)); } @@ -861,7 +864,7 @@ char *client_uagent(const struct parsers *v, char *s, struct client_state *csp) if (*uagent == '@') { - if (csp->send_user_cookie) + if (csp->permissions & PERMIT_COOKIE_READ) { return(strdup(s)); } @@ -910,7 +913,7 @@ char *client_ua(const struct parsers *v, char *s, struct client_state *csp) if (*uagent == '@') { - if (csp->send_user_cookie) + if (csp->permissions & PERMIT_COOKIE_READ) { return(strdup(s)); } @@ -984,7 +987,7 @@ char *client_from(const struct parsers *v, char *s, struct client_state *csp) *********************************************************************/ char *client_send_cookie(const struct parsers *v, char *s, struct client_state *csp) { - if (csp->send_user_cookie) + if (csp->permissions & PERMIT_COOKIE_READ) { enlist(csp->cookie_list, s + v->len + 1); } @@ -1219,7 +1222,7 @@ char *server_set_cookie(const struct parsers *v, char *s, struct client_state *c } #endif /* def JAR_FILES */ - if (csp->accept_server_cookie == 0) + if (!(csp->permissions & PERMIT_COOKIE_SET)) { return(crumble(v, s, csp)); } diff --git a/parsers.h b/parsers.h index 14025448..ad3521b9 100644 --- a/parsers.h +++ b/parsers.h @@ -1,9 +1,9 @@ #ifndef _PARSERS_H #define _PARSERS_H -#define PARSERS_H_VERSION "$Id: parsers.h,v 1.1 2001/05/13 21:57:06 administrator Exp $" +#define PARSERS_H_VERSION "$Id: parsers.h,v 1.1.1.1 2001/05/15 13:59:01 oes Exp $" /********************************************************************* * - * File : $Source: /home/administrator/cvs/ijb/parsers.h,v $ + * File : $Source: /cvsroot/ijbswa/current/parsers.h,v $ * * Purpose : Declares functions to parse/crunch headers and pages. * Functions declared include: @@ -43,6 +43,9 @@ * * Revisions : * $Log: parsers.h,v $ + * Revision 1.1.1.1 2001/05/15 13:59:01 oes + * Initial import of version 2.9.3 source tree + * * *********************************************************************/ @@ -84,9 +87,9 @@ extern void client_xtra_adder(struct client_state *csp); extern void client_x_forwarded_adder(struct client_state *csp); extern char *server_set_cookie(const struct parsers *v, char *s, struct client_state *csp); -#ifdef PCRS +#if defined(PCRS) || defined(KILLPOPUPS) extern char *content_type(const struct parsers *v, char *s, struct client_state *csp); -#endif /* def PCRS */ +#endif /* defined(PCRS) || defined(KILLPOPUPS) */ #ifdef FORCE_LOAD char *client_host(const struct parsers *v, char *s, struct client_state *csp); diff --git a/permissionsfile b/permissionsfile new file mode 100755 index 00000000..d49f2c17 --- /dev/null +++ b/permissionsfile @@ -0,0 +1,108 @@ +# Sample permissions file for the Internet Junkbuster 2.9.4 +# +# For information, see http://ijbswa.sourceforge.net/ +# +# Empty lines and lines beginning with a # are ignored. +# +# Each line has the following format: +# [flags][domain][:port][/path] +# +# There should be no spaces between the components. +# +# The domain, port, and path parts make up the pattern used +# to match URLs. The port part must be a number and must +# match exactly. The domain part is matched by comparing +# each sub-domain (between the dots) from right to left. +# e.g.: +# - The pattern "com" matches "anything.com" +# - The pattern "yahoo.com" would match "mail.yahoo.com", +# "login.yahoo.com", "www.yahoo.com", or "yahoo.com". +# "*" characters are allowed immediately before a dot or at +# the end of the domain, and match anything. e.g.: +# - "microsoft.*" matches "microsoft.com" and "microsoft.net", +# (and "www.microsoft.com", "office.microsoft.com", etc) +# but not "microsoft.xyz.com" or "microsoft.co.uk". +# - "ad*.*.*.*" matches "ad.doubleclick.co.uk" +# - "*.*click.*.*" is invalid ("*" is not followed by ".") +# +# The path part is a prefix match (if JunkBuster was compiled +# without REGEX), or a POSIX regular expression (if JunkBuster +# was compiled with REXEX but not PCRE), or a PERL (PCRE) +# regular expression (if JunkBuster was compiled with the +# default options). "^" is automatically prepended to the RE +# before the "/". +# +# Flags are: +# > Allow cookies to be read by the website, but not set. +# < Allow cookies to be set by the website, but not read. +# <> Block all cookies. +# % Enable re_filterfile processing for this site +# ^ Block popups from this site. +# ~ Same as all of <>%^ +# (no flags) Allow cookies and popups, don't re_filter. +# +# Multiple flags (up to 4) may be specified. +# +# If a web page's URL matches the specified pattern, then the +# flags specified for that site are used. If it matches more +# than one pattern, then the first match (searching top-to-bottom +# in this file) is used. +# +# If a URL does not match any of the patterns in this file, +# then the default settings are used. The default can be set +# by a line in this file which contains flags but no pattern. +# If this is not specified, then the default is ~ +# +# +# EXAMPLES: +# +# To permit an entire site to set cookies, simply include its domain name: +# really-trustyworthy-people.org +# +# You can allow cookies out, but stop them coming in: +# >%^send-user-cookies.com +# +# dabs.com requires cookies and popups: +# %dabs.com +# +# Windows Update is fragile, so allow everything: +# windowsupdate.microsoft.com +# +# +#%^>tvguide.com +#%^>wired.com/news/ +#%^americanexpress.com +#%^cnn.com +#%^www.nytimes.com +#%^amazon.de +#%^amazon.co.uk +#%^slashdot.org +#%^www.palmgear.com +#%^onelist.com +#%^freshmeat.net + +# Sites that need cookies +%^javasoft.com +%^sun.com +%^msdn.microsoft.com +%^sourceforge.net +%^yahoo.com + +# These sites are very complex and require +# minimal interference. +office.microsoft.com +windowsupdate.microsoft.com + +# Shopping +dabs.com +overclockers.co.uk +worldpay.com # for quietpc.com +jungle.com +scan.co.uk + +# Explicitly set default to ~ +~ + + +# End of file + diff --git a/popup b/popup deleted file mode 100644 index 07f0c36b..00000000 --- a/popup +++ /dev/null @@ -1,44 +0,0 @@ -# -# $Id: popup,v 1.1 2001/04/16 21:10:38 rodney Exp $ -# -# This is the configuration file for blocking Javascript popup windows, -# it specifies both hosts to block from, and hosts to allow the popups -# from. -# -# The format is the hostname to block, or allow. -# -# eg: -# -# www.geocities.com # block all popups from geocities. -# -# ~www.trusted-host.com # Allow popups from the trusted host domain. -# -# -# If a site is not explicitly blocked popups will be allowed, the -# "allowable" syntax with "~" exists as a marker that you've explicitly -# allowed something. -# -# Order is not relevant - an allowable entry overrides a blocked entry, -# e.g. -# ~myhost.com # Allows myhost.com -# myhost.com # _Still_ allowed. -# -# Steve Kemp -# --- -# http://www.tardis.ed.ac.uk/~skx/junk/ for more details. -# -# - - - -# This is for the test page, at http://www.tardis.ed.ac.uk/~skx/junk/ -www.tardis.ed.ac.uk - -# -# Samples, uncomment to use: -# - -# members.tripod.co.uk -# www.geocities.com -# ~windowsupdates.microsoft.com -# ~updates.microsoft.com \ No newline at end of file diff --git a/project.h b/project.h index 49415826..7371d659 100644 --- a/project.h +++ b/project.h @@ -1,6 +1,6 @@ #ifndef _PROJECT_H #define _PROJECT_H -#define PROJECT_H_VERSION "$Id: project.h,v 1.1.1.1 2001/05/15 13:59:03 oes Exp $" +#define PROJECT_H_VERSION "$Id: project.h,v 1.2 2001/05/17 23:01:01 oes Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/project.h,v $ @@ -36,6 +36,9 @@ * * Revisions : * $Log: project.h,v $ + * 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:59:03 oes * Initial import of version 2.9.3 source tree * @@ -185,8 +188,8 @@ struct list struct client_state { - int send_user_cookie; - int accept_server_cookie; + int permissions; + int cfd; int sfd; @@ -228,9 +231,9 @@ struct client_state struct list headers[1]; struct list cookie_list[1]; -#ifdef PCRS +#if defined(PCRS) || defined(KILLPOPUPS) int is_text; -#endif /* def PCRS */ +#endif /* defined(PCRS) || defined(KILLPOPUPS) */ char *x_forwarded; @@ -238,21 +241,18 @@ struct client_state /* files associated with this client */ struct file_list *blist; /* blockfile */ - struct file_list *clist; /* cookiefile */ struct file_list *flist; /* forwardfile */ + struct file_list *permissions_list; + -#ifdef ACL_FILES +#ifdef ACL_FILES struct file_list *alist; /* aclfile */ #endif /* def ACL_FILES */ #ifdef USE_IMAGE_LIST struct file_list *ilist; /* imagefile */ #endif /* def USE_IMAGE_LIST */ - -#ifdef KILLPOPUPS - struct file_list *plist; /* kill popup file */ -#endif /* def KILLPOPUPS */ - + #ifdef PCRS struct file_list *rlist; /* Perl re_filterfile */ #endif /* def PCRS */ @@ -260,7 +260,7 @@ struct client_state #ifdef TRUST_FILES struct file_list *tlist; /* trustfile */ #endif /* def TRUST_FILES */ - + struct client_state *next; }; @@ -346,20 +346,23 @@ struct file_list struct block_spec { struct url_spec url[1]; - int reject; + int reject; struct block_spec *next; }; - - -struct cookie_spec -{ - struct url_spec url[1]; - int send_user_cookie; - int accept_server_cookie; - struct cookie_spec *next; -}; - - + + +#define PERMIT_COOKIE_SET 0x0001 +#define PERMIT_COOKIE_READ 0x0002 +#define PERMIT_RE_FILTER 0x0004 +#define PERMIT_POPUPS 0x0008 + +struct permissions_spec +{ + struct url_spec url[1]; + int permissions; + struct permissions_spec * next; +}; + struct forward_spec { struct url_spec url[1]; @@ -377,23 +380,7 @@ struct re_filterfile_spec pcrs_job *joblist; }; #endif /* def PCRS */ - - -#ifdef KILLPOPUPS -/* Entries on popup blocklist */ -struct popup_blocklist -{ - char *host_name; - struct popup_blocklist *next; -}; - -/* Actual type used in file object */ -struct popup_settings -{ - struct popup_blocklist *blocked; - struct popup_blocklist *allowed; -}; -#endif /* def KILLPOPUPS */ + #ifdef ACL_FILES #define ACL_PERMIT 1 /* accept connection request */ diff --git a/showargs.c b/showargs.c index 98d90446..999b60c1 100644 --- a/showargs.c +++ b/showargs.c @@ -1,4 +1,4 @@ -const char showargs_rcs[] = "$Id: showargs.c,v 1.1.1.1 2001/05/15 13:59:03 oes Exp $"; +const char showargs_rcs[] = "$Id: showargs.c,v 1.2 2001/05/17 23:01:01 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/showargs.c,v $ @@ -33,6 +33,9 @@ const char showargs_rcs[] = "$Id: showargs.c,v 1.1.1.1 2001/05/15 13:59:03 oes E * * Revisions : * $Log: showargs.c,v $ + * 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:59:03 oes * Initial import of version 2.9.3 source tree * @@ -100,16 +103,16 @@ char *strsav(char *old, const char *text_to_append) { if ((p = realloc(old, new_len)) == NULL) { - log_error(LOG_LEVEL_ERROR, "realloc(%d) bytes for proxy_args failed!", new_len); - exit(1); + log_error(LOG_LEVEL_FATAL, "realloc(%d) bytes for proxy_args failed!", new_len); + /* Never get here - LOG_LEVEL_FATAL causes program exit */ } } else { if ((p = (char *)malloc(new_len)) == NULL) { - log_error(LOG_LEVEL_ERROR, "malloc(%d) bytes for proxy_args failed!", new_len); - exit(1); + log_error(LOG_LEVEL_FATAL, "malloc(%d) bytes for proxy_args failed!", new_len); + /* Never get here - LOG_LEVEL_FATAL causes program exit */ } } diff --git a/w32.rc b/w32.rc index 99cdac26..5d991a44 100644 --- a/w32.rc +++ b/w32.rc @@ -1,6 +1,6 @@ /********************************************************************* * - * File : $Source: $ + * File : $Source: /cvsroot/ijbswa/current/w32.rc,v $ * * Purpose : Windows GUI resource script. * @@ -30,7 +30,10 @@ * Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Revisions : - * $Log:$ + * $Log: w32.rc,v $ + * Revision 1.1.1.1 2001/05/15 13:59:07 oes + * Initial import of version 2.9.3 source tree + * * *********************************************************************/ @@ -97,7 +100,7 @@ BEGIN MENUITEM "&Junkbuster...", ID_TOOLS_EDITJUNKBUSTER MENUITEM SEPARATOR MENUITEM "&Blockers...", ID_TOOLS_EDITBLOCKERS - MENUITEM "&Cookies...", ID_TOOLS_EDITCOOKIES + MENUITEM "&Permissions...", ID_TOOLS_EDITPERMISSIONS MENUITEM "&Forward...", ID_TOOLS_EDITFORWARD #ifdef ACL_FILES MENUITEM "&Access Control Lists...", ID_TOOLS_EDITACLS @@ -105,9 +108,6 @@ BEGIN #ifdef USE_IMAGE_LIST MENUITEM "&Images...", ID_TOOLS_EDITIMAGE #endif /* def USE_IMAGE_LIST */ -#ifdef KILLPOPUPS - MENUITEM "&Popups...", ID_TOOLS_EDITPOPUPS -#endif /* def KILLPOPUPS */ #ifdef PCRS MENUITEM "Perl &Regexps...", ID_TOOLS_EDITPERLRE #endif /* def PCRS */ @@ -153,7 +153,7 @@ BEGIN MENUITEM "&Junkbuster...", ID_TOOLS_EDITJUNKBUSTER MENUITEM SEPARATOR MENUITEM "&Blockers...", ID_TOOLS_EDITBLOCKERS - MENUITEM "&Cookies...", ID_TOOLS_EDITCOOKIES + MENUITEM "&Permissions...", ID_TOOLS_EDITPERMISSIONS MENUITEM "&Forward...", ID_TOOLS_EDITFORWARD #ifdef ACL_FILES MENUITEM "&Access Control Lists...",ID_TOOLS_EDITACLS @@ -161,9 +161,6 @@ BEGIN #ifdef USE_IMAGE_LIST MENUITEM "&Images...", ID_TOOLS_EDITIMAGE #endif /* def USE_IMAGE_LIST */ -#ifdef KILLPOPUPS - MENUITEM "&Popups...", ID_TOOLS_EDITPOPUPS -#endif /* def KILLPOPUPS */ #ifdef PCRS MENUITEM "Perl &Regexps...", ID_TOOLS_EDITPERLRE #endif /* def PCRS */ diff --git a/w32log.c b/w32log.c index 975c5e0f..6904c796 100644 --- a/w32log.c +++ b/w32log.c @@ -1,7 +1,7 @@ -const char w32log_rcs[] = "$Id: w32log.c,v 1.1 2001/05/13 21:57:07 administrator Exp $"; +const char w32log_rcs[] = "$Id: w32log.c,v 1.1.1.1 2001/05/15 13:59:07 oes Exp $"; /********************************************************************* * - * File : $Source: /home/administrator/cvs/ijb/w32log.c,v $ + * File : $Source: /cvsroot/ijbswa/current/w32log.c,v $ * * Purpose : Functions for creating and destroying the log window, * ouputting strings, processing messages and so on. @@ -32,6 +32,9 @@ const char w32log_rcs[] = "$Id: w32log.c,v 1.1 2001/05/13 21:57:07 administrator * * Revisions : * $Log: w32log.c,v $ + * Revision 1.1.1.1 2001/05/15 13:59:07 oes + * Initial import of version 2.9.3 source tree + * * *********************************************************************/ @@ -1042,8 +1045,8 @@ void OnLogCommand(int nCommand) EditFile(blockfile); break; - case ID_TOOLS_EDITCOOKIES: - EditFile(cookiefile); + case ID_TOOLS_EDITPERMISSIONS: + EditFile(permissions_file); break; case ID_TOOLS_EDITFORWARD: @@ -1068,12 +1071,6 @@ void OnLogCommand(int nCommand) break; #endif -#ifdef KILLPOPUPS - case ID_TOOLS_EDITPOPUPS: - EditFile(popupfile); - break; -#endif /* def KILLPOPUPS */ - #ifdef TRUST_FILES case ID_TOOLS_EDITTRUST: EditFile(trustfile); @@ -1128,7 +1125,7 @@ void OnLogCommand(int nCommand) void OnLogInitMenu(HMENU hmenu) { /* Only enable editors if there is a file to edit */ - EnableMenuItem(hmenu, ID_TOOLS_EDITCOOKIES, MF_BYCOMMAND | (cookiefile ? MF_ENABLED : MF_GRAYED)); + EnableMenuItem(hmenu, ID_TOOLS_EDITPERMISSIONS, MF_BYCOMMAND | (permissions_file ? MF_ENABLED : MF_GRAYED)); EnableMenuItem(hmenu, ID_TOOLS_EDITBLOCKERS, MF_BYCOMMAND | (blockfile ? MF_ENABLED : MF_GRAYED)); EnableMenuItem(hmenu, ID_TOOLS_EDITFORWARD, MF_BYCOMMAND | (forwardfile ? MF_ENABLED : MF_GRAYED)); #ifdef ACL_FILES @@ -1137,9 +1134,6 @@ void OnLogInitMenu(HMENU hmenu) #ifdef USE_IMAGE_LIST EnableMenuItem(hmenu, ID_TOOLS_EDITIMAGE, MF_BYCOMMAND | (imagefile ? MF_ENABLED : MF_GRAYED)); #endif /* def USE_IMAGE_LIST */ -#ifdef KILLPOPUPS - EnableMenuItem(hmenu, ID_TOOLS_EDITPOPUPS, MF_BYCOMMAND | (popupfile ? MF_ENABLED : MF_GRAYED)); -#endif /* def KILLPOPUPS */ #ifdef PCRS EnableMenuItem(hmenu, ID_TOOLS_EDITPERLRE, MF_BYCOMMAND | (re_filterfile ? MF_ENABLED : MF_GRAYED)); #endif diff --git a/w32res.h b/w32res.h index 7fb57b6a..002872e5 100644 --- a/w32res.h +++ b/w32res.h @@ -1,9 +1,9 @@ #ifndef _W32RES_H #define _W32RES_H -#define W32RES_H_VERSION "$Id: w32res.h,v 1.1 2001/05/13 21:57:07 administrator Exp $" +#define W32RES_H_VERSION "$Id: w32res.h,v 1.1.1.1 2001/05/15 13:59:08 oes Exp $" /********************************************************************* * - * File : $Source: /home/administrator/cvs/ijb/w32res.h,v $ + * File : $Source: /cvsroot/ijbswa/current/w32res.h,v $ * * Purpose : Identifiers for Windows GUI resources. * @@ -34,6 +34,9 @@ * * Revisions : * $Log: w32res.h,v $ + * Revision 1.1.1.1 2001/05/15 13:59:08 oes + * Initial import of version 2.9.3 source tree + * * *********************************************************************/ @@ -88,7 +91,7 @@ /* Break these out so they are easier to extend, but keep consecutive */ #define ID_TOOLS_EDITJUNKBUSTER 5000 #define ID_TOOLS_EDITBLOCKERS 5001 -#define ID_TOOLS_EDITCOOKIES 5002 +#define ID_TOOLS_EDITPERMISSIONS 5002 #define ID_TOOLS_EDITFORWARD 5003 #ifdef ACL_FILES @@ -99,10 +102,6 @@ #define ID_TOOLS_EDITIMAGE 5006 #endif /* def USE_IMAGE_LIST */ -#ifdef KILLPOPUPS -#define ID_TOOLS_EDITPOPUPS 5007 -#endif /* def KILLPOPUPS */ - #ifdef PCRS #define ID_TOOLS_EDITPERLRE 5008 #endif /* def PCRS */