-const char filters_rcs[] = "$Id: filters.c,v 1.7 2001/05/26 15:26:15 jongfoster Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.8 2001/05/26 17:13:28 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/filters.c,v $
*
* Revisions :
* $Log: filters.c,v $
+ * Revision 1.8 2001/05/26 17:13:28 jongfoster
+ * Filled in a function comment.
+ *
* Revision 1.7 2001/05/26 15:26:15 jongfoster
* ACL feature now provides more security by immediately dropping
* connections from untrusted hosts.
* Function : re_process_buffer
*
* Description : Apply all jobs from the joblist (aka. Perl regexp's) to
- * the text buffer that's been accumulated in csp->iob->buf.
- * Then, write the modified buffer out to the client
- * (Maybe this should happen from jcc.c via flush_socket
- * for better readability).
+ * the text buffer that's been accumulated in csp->iob->buf
+ * and set csp->content_length to the modified size.
*
* Parameters :
* 1 : csp = Current client state (buffers, headers, etc...)
*
- * Returns : N/A
+ * Returns : a pointer to the (newly allocated) modified buffer.
+ *
*
*********************************************************************/
-void re_process_buffer(struct client_state *csp)
+char *re_process_buffer(struct client_state *csp)
{
int hits=0;
int size = csp->iob->eod - csp->iob->cur;
log_error(LOG_LEVEL_RE_FILTER, " produced %d hits (new size %d).", hits, size);
- if (write_socket(csp->cfd, old, size) != size)
- {
- log_error(LOG_LEVEL_ERROR, "write to client failed.");
- }
+ csp->content_length = size;
/* fwiw, reset the iob */
IOB_RESET(csp);
- freez(new);
- return;
+ return(new);
}
#endif /* def PCRS */
#ifndef _FILTERS_H
#define _FILTERS_H
-#define FILTERS_H_VERSION "$Id: filters.h,v 1.3 2001/05/22 18:46:04 oes Exp $"
+#define FILTERS_H_VERSION "$Id: filters.h,v 1.4 2001/05/26 15:26:15 jongfoster Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/filters.h,v $
*
* Revisions :
* $Log: filters.h,v $
+ * Revision 1.4 2001/05/26 15:26:15 jongfoster
+ * ACL feature now provides more security by immediately dropping
+ * connections from untrusted hosts.
+ *
* Revision 1.3 2001/05/22 18:46:04 oes
*
* - Enabled filtering banners by size rather than URL
#endif /* def STATISTICS */
#ifdef PCRS
-extern void re_process_buffer(struct client_state *csp);
+extern char *re_process_buffer(struct client_state *csp);
#endif /* def PCRS */
/* Revision control strings from this header and associated .c file */
-const char jcc_rcs[] = "$Id: jcc.c,v 1.10 2001/05/26 15:26:15 jongfoster Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.11 2001/05/26 17:27:53 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
*
* Revisions :
* $Log: jcc.c,v $
+ * Revision 1.11 2001/05/26 17:27:53 jongfoster
+ * Added support for CLF and fixed LOG_LEVEL_LOG.
+ * Also did CRLF->LF fix of my previous patch.
+ *
* Revision 1.10 2001/05/26 15:26:15 jongfoster
* ACL feature now provides more security by immediately dropping
* connections from untrusted hosts.
#ifdef PCRS
if (filtering)
{
- re_process_buffer(csp);
+ p = re_process_buffer(csp);
+ hdr = sed(server_patterns, add_server_headers, csp);
+ n = strlen(hdr);
+ if ((write_socket(csp->cfd, hdr, n) != n)
+ || (write_socket(csp->cfd, p, csp->content_length) != csp->content_length))
+ {
+ log_error(LOG_LEVEL_CONNECT, "write modified content to client failed: %E");
+ return;
+ }
+ freez(hdr);
+ freez(p);
}
#endif /* def PCRS */
break; /* "game over, man" */
if (csp->is_text && /* It's a text / * MIME-Type */
!http->ssl && /* We talk plaintext */
- block_popups)
+ block_popups) /* Policy allows */
{
block_popups_now = 1;
}
#endif /* def PCRS */
- if ((write_socket(csp->cfd, hdr, n) != n)
- || (NOT_FILTERING_AND (n = flush_socket(csp->cfd, csp) < 0)))
+ if (NOT_FILTERING_AND ((write_socket(csp->cfd, hdr, n) != n)
+ || (n = flush_socket(csp->cfd, csp) < 0)))
{
log_error(LOG_LEVEL_CONNECT, "write header to client failed: %E");
#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) */
sweep();
- if ( NULL == (csp = (struct client_state *) malloc(sizeof(*csp))) )
+ if ( NULL == (csp = (struct client_state *) zalloc(sizeof(*csp))) )
{
log_error(LOG_LEVEL_FATAL, "malloc(%d) for csp failed: %E", sizeof(*csp));
continue;
-const char parsers_rcs[] = "$Id: parsers.c,v 1.6 2001/05/26 13:39:32 jongfoster Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.7 2001/05/27 13:19:06 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/parsers.c,v $
*
* Revisions :
* $Log: parsers.c,v $
+ * Revision 1.7 2001/05/27 13:19:06 oes
+ * Patched Joergs solution for the content-length in.
+ *
* Revision 1.6 2001/05/26 13:39:32 jongfoster
* Only crunches Content-Length header if applying RE filtering.
* Without this fix, Microsoft Windows Update wouldn't work.
{
for (p = csp->headers->next; p ; p = p->next)
{
+ /* Header crunch()ed in previous run? -> ignore */
+ if (p->str == NULL) continue;
+
if (v == pats) log_error(LOG_LEVEL_HEADER, "scan: %s", p->str);
- if (p->str == NULL)
- {
- /* hit me */
- log_error(LOG_LEVEL_ERROR, "NULL header");
- }
- else if (strncmpic(p->str, v->str, v->len) == 0)
+ if (strncmpic(p->str, v->str, v->len) == 0)
{
hdr = v->parser(v, p->str, csp);
freez(p->str);
(*f)(csp);
}
- /* add the blank line at the end of the header */
- enlist(csp->headers, "");
+ /* add the blank line at the end of the header, if necessary */
+ if(strlen(csp->headers->last->str) != 0)
+ {
+ enlist(csp->headers, "");
+ }
hdr = list_to_text(csp->headers);
*********************************************************************/
char *content_length(const struct parsers *v, char *s, struct client_state *csp)
{
- if (((csp->permissions & PERMIT_RE_FILTER) != 0) && csp->is_text)
- {
- log_error(LOG_LEVEL_HEADER, "crunch!");
- return(NULL);
- }
+ if (csp->content_length != 0) /* Content has been modified */
+ {
+ s = (char *) zalloc(100);
+ snprintf(s, 100, "Content-Length: %d", csp->content_length);
+ log_error(LOG_LEVEL_HEADER, "Adjust Content-Length to %d", csp->content_length);
+ return(s);
+ }
else
{
return(strdup(s));
#ifndef _PROJECT_H
#define _PROJECT_H
-#define PROJECT_H_VERSION "$Id: project.h,v 1.4 2001/05/22 18:46:04 oes Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.5 2001/05/26 00:28:36 jongfoster Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/project.h,v $
*
* Revisions :
* $Log: project.h,v $
+ * Revision 1.5 2001/05/26 00:28:36 jongfoster
+ * Automatic reloading of config file.
+ * Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
+ * Most of the global variables have been moved to a new
+ * struct configuration_spec, accessed through csp->config->globalname
+ * Most of the globals remaining are used by the Win32 GUI.
+ *
* Revision 1.4 2001/05/22 18:46:04 oes
*
* - Enabled filtering banners by size rather than URL
#endif /* def FORCE_LOAD */
#ifdef TOGGLE
- /*
- * by haroon - most of credit to srt19170
- * We add an "on/off" toggle here that is used to effectively toggle
- * the Junkbuster off or on
- */
int toggled_on;
-#endif
+#endif /* def TOGGLE */
char *ip_addr_str;
long ip_addr_long;
#ifdef PCRS
struct file_list *rlist; /* Perl re_filterfile */
+ size_t content_length; /* Length after processing */
#endif /* def PCRS */
#ifdef TRUST_FILES