-const char actions_rcs[] = "$Id: actions.c,v 1.15 2001/10/14 21:58:22 jongfoster Exp $";
+const char actions_rcs[] = "$Id: actions.c,v 1.16 2001/10/23 21:30:30 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/actions.c,v $
* IJBSWA team. http://ijbswa.sourceforge.net
*
* Based on the Internet Junkbuster originally written
- * by and Copyright (C) 1997 Anonymous Coders and
+ * by and Copyright (C) 1997 Anonymous Coders and
* Junkbusters Corporation. http://www.junkbusters.com
*
- * This program is free software; you can redistribute it
+ * This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
*
* Revisions :
* $Log: actions.c,v $
+ * Revision 1.16 2001/10/23 21:30:30 jongfoster
+ * Adding error-checking to selected functions.
+ *
* Revision 1.15 2001/10/14 21:58:22 jongfoster
* Adding support for the CGI-based editor:
* - Exported get_actions()
#define AV_REM_MULTI 4 /* -multiopt{string} -multiopt{*} */
/*
- * We need a structure to hold the name, flag changes,
+ * We need a structure to hold the name, flag changes,
* type, and string index.
*/
struct action_name
* Returns : JB_ERR_OK or JB_ERR_MEMORY
*
*********************************************************************/
-jb_err merge_actions (struct action_spec *dest,
+jb_err merge_actions (struct action_spec *dest,
const struct action_spec *src)
{
int i;
* Returns : N/A
*
*********************************************************************/
-jb_err copy_action (struct action_spec *dest,
+jb_err copy_action (struct action_spec *dest,
const struct action_spec *src)
{
int i;
- jb_err err;
+ jb_err err = JB_ERR_OK;
memset(dest, '\0', sizeof(*dest));
return err;
}
}
+ return err;
}
* we found an action.
* 2 : name = [out] Start of action name, null
* terminated. NULL on EOL
- * 3 : value = [out] Start of action value, null
+ * 3 : value = [out] Start of action value, null
* terminated. NULL if none or EOL.
*
* Returns : JB_ERR_OK => Ok
*name = str;
/* parse option */
- while (((ch = *str) != '\0') &&
+ while (((ch = *str) != '\0') &&
(ch != ' ') && (ch != '\t') && (ch != '{'))
{
if (ch == '}')
if (option)
{
/* handle option in 'option' */
-
+
/* Check for standard action name */
const struct action_name * action = action_names;
{
/* try user aliases. */
const struct action_alias * alias = alias_list;
-
+
while ( (alias != NULL) && (0 != strcmpic(alias->name, option)) )
{
alias = alias->next;
* 1 : dest = Current actions, to modify.
* 2 : src = Action to add.
*
- * Returns : N/A
+ * Returns 0 : no error
+ * !=0 : error
*
*********************************************************************/
-jb_err merge_current_action (struct current_action_spec *dest,
+jb_err merge_current_action (struct current_action_spec *dest,
const struct action_spec *src)
{
int i;
- jb_err err;
+ jb_err err = JB_ERR_OK;
dest->flags &= src->mask;
dest->flags |= src->add;
}
}
}
+ return err;
}
{
struct action_alias * next = alias_list->next;
alias_list->next = NULL;
- freez((char *)alias_list->name);
+ freez(alias_list->name);
free_action(alias_list->action);
free(alias_list);
alias_list = next;
{
/* too short */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid line: %s",
csp->config->actions_file, buf);
return 1; /* never get here */
{
/* too short */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid line: {{ }}",
csp->config->actions_file);
return 1; /* never get here */
* appear once.
*/
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': {{settings}} must only appear once, and it must be before anything else.",
csp->config->actions_file);
}
/* {{description}} is a singleton and only {{settings}} may proceed it
*/
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': {{description}} must only appear once, and only a {{settings}} block may be above it.",
csp->config->actions_file);
}
* completely rewriting the file becomes non-trivial)
*/
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': {{alias}} must only appear once, and it must be before all actions.",
csp->config->actions_file, start);
}
{
/* invalid {{something}} block */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid line: {{%s}}",
csp->config->actions_file, start);
return 1; /* never get here */
if (cur_action == NULL)
{
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': out of memory",
csp->config->actions_file);
return 1; /* never get here */
{
/* No closing } */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid line: %s",
csp->config->actions_file, buf);
return 1; /* never get here */
{
/* error */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid line: %s",
csp->config->actions_file, buf);
return 1; /* never get here */
if ((start == NULL) || (start == buf))
{
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid alias line: %s",
csp->config->actions_file, buf);
return 1; /* never get here */
}
if (*start == '\0')
{
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid alias line: %s",
csp->config->actions_file, buf);
return 1; /* never get here */
{
/* error */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': invalid alias line: %s = %s",
csp->config->actions_file, buf, start);
return 1; /* never get here */
}
-
+
/* add to list */
new_alias->next = alias_list;
alias_list = new_alias;
if (create_url_spec(perm->url, buf))
{
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': cannot create URL pattern from: %s",
csp->config->actions_file, buf);
return 1; /* never get here */
{
/* oops - please have a {} line as 1st line in file. */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': first line is invalid: %s",
csp->config->actions_file, buf);
return 1; /* never get here */
{
/* How did we get here? This is impossible! */
fclose(fp);
- log_error(LOG_LEVEL_FATAL,
+ log_error(LOG_LEVEL_FATAL,
"can't load actions file '%s': INTERNAL ERROR - mode = %d",
csp->config->actions_file, mode);
return 1; /* never get here */
}
fclose(fp);
-
+
free_action(cur_action);
free_alias_list(alias_list);
-const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.3 2001/10/14 22:12:49 jongfoster Exp $";
+const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.4 2001/10/23 21:48:19 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgiedit.c,v $
*
* Purpose : CGI-based actionsfile editor.
- *
+ *
* Functions declared include:
- *
+ *
*
* Copyright : Written by and Copyright (C) 2001 the SourceForge
* IJBSWA team. http://ijbswa.sourceforge.net
*
* Based on the Internet Junkbuster originally written
- * by and Copyright (C) 1997 Anonymous Coders and
+ * by and Copyright (C) 1997 Anonymous Coders and
* Junkbusters Corporation. http://www.junkbusters.com
*
- * This program is free software; you can redistribute it
+ * This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
*
* Revisions :
* $Log: cgiedit.c,v $
+ * Revision 1.4 2001/10/23 21:48:19 jongfoster
+ * Cleaning up error handling in CGI functions - they now send back
+ * a HTML error page and should never cause a FATAL error. (Fixes one
+ * potential source of "denial of service" attacks).
+ *
+ * CGI actions file editor that works and is actually useful.
+ *
+ * Ability to toggle JunkBuster remotely using a CGI call.
+ *
+ * You can turn off both the above features in the main configuration
+ * file, e.g. if you are running a multi-user proxy.
+ *
* Revision 1.3 2001/10/14 22:12:49 jongfoster
* New version of CGI-based actionsfile editor.
* Major changes, including:
#define snprintf _snprintf
#endif /* def _WIN32 */
+#ifdef __OS2__
+/*
+ * FIXME: gotta write a snprintf routine. snprintf. You guys kill me.
+ */
+#define snprintf(X,Y,Z) sprintf(X,Z)
+#endif /* __OS2__ */
+
#include "project.h"
#include "cgi.h"
#include "cgiedit.h"
char * prefix;
char * unprocessed;
int type;
-
+
union
{
struct action_spec action[1];
* significant anyway.
*/
struct file_line * parse_error; /* On parse error, this is the offending line. */
- const char * parse_error_text; /* On parse error, this is the problem.
+ const char * parse_error_text; /* On parse error, this is the problem.
* (Statically allocated) */
};
/* Internal actionsfile <==> HTML conversion functions */
static jb_err map_radio(struct map * exports,
- const char * optionname,
+ const char * optionname,
const char * values,
char value);
static jb_err actions_to_radio(struct map * exports,
{
return JB_ERR_MEMORY;
}
-
+
*buf = '\0';
len = 0;
*dest = buf;
return JB_ERR_OK;
}
-
+
if (NULL == (newbuf = realloc(buf, len + BUFFER_SIZE)))
{
free(buf);
* and respects escaping of newline and comment char.
* Provides the line in 2 alternative forms: raw and
* preprocessed.
- * - raw is the raw data read from the file. If the
+ * - raw is the raw data read from the file. If the
* line is not modified, then this should be written
* to the new file.
* - prefix is any comments and blank lines that were
free(linebuf);
return JB_ERR_MEMORY;
}
-
+
/* Trim off newline */
p = linebuf + strlen(linebuf);
if ((p != linebuf) && ((p[-1] == '\r') || (p[-1] == '\n')))
{
/* Got at least some data */
- /* Remove trailing whitespace */
+ /* Remove trailing whitespace */
chomp(data);
if (raw_out)
file->version = (unsigned)statbuf->st_mtime;
/* Correct file->version_str */
- freez((char *)file->version_str);
+ freez(file->version_str);
snprintf(version_buf, 22, "%u", file->version);
version_buf[21] = '\0';
file->version_str = strdup(version_buf);
*
* Function : edit_free_file
*
- * Description : Free a complete file in memory.
+ * Description : Free a complete file in memory.
*
* Parameters :
* 1 : file = Data structure to free.
}
edit_free_file_lines(file->lines);
- freez((char *)file->filename);
- freez((char *)file->identifier);
- freez((char *)file->version_str);
+ freez(file->filename);
+ freez(file->identifier);
+ freez(file->version_str);
file->version = 0;
file->parse_error_text = NULL; /* Statically allocated */
file->parse_error = NULL;
*
* Function : edit_free_file
*
- * Description : Free an entire linked list of file lines.
+ * Description : Free an entire linked list of file lines.
*
* Parameters :
* 1 : first_line = Data structure to free.
*
* Function : match_actions_file_header_line
*
- * Description : Match an actions file {{header}} line
+ * Description : Match an actions file {{header}} line
*
* Parameters :
* 1 : line - String from file
*
* Function : match_actions_file_header_line
*
- * Description : Match an actions file {{header}} line
+ * Description : Match an actions file {{header}} line
*
* Parameters :
* 1 : line - String from file. Must not start with
*
* Function : edit_parse_actions_file
*
- * Description : Parse an actions file in memory.
+ * Description : Parse an actions file in memory.
*
* Passed linked list must have the "data" member
* zeroed, and must contain valid "next" and
cur_line = file->lines;
- /* A note about blank line support: Blank lines should only
+ /* A note about blank line support: Blank lines should only
* ever occur as the last line in the file. This function
* is more forgiving than that - FILE_LINE_BLANK can occur
* anywhere.
*
* Function : edit_read_file_lines
*
- * Description : Read all the lines of a file into memory.
+ * Description : Read all the lines of a file into memory.
* Handles whitespace, comments and line continuation.
*
* Parameters :
}
/* Correct file->version_str */
- freez((char *)file->version_str);
+ freez(file->version_str);
snprintf(version_buf, 22, "%u", file->version);
version_buf[21] = '\0';
file->version_str = strdup(version_buf);
*
* <limits.h> defines UINT_MAX
*
- * (UINT_MAX - ch) / 10 is the largest number that
+ * (UINT_MAX - ch) / 10 is the largest number that
* can be safely multiplied by 10 then have ch added.
*/
if (value > ((UINT_MAX - (unsigned)ch) / 10U))
*
*********************************************************************/
static jb_err map_radio(struct map * exports,
- const char * optionname,
+ const char * optionname,
const char * values,
char value)
{
char * buf;
char * p;
char c;
-
+
assert(exports);
assert(optionname);
assert(values);
*
* Description : CGI function that is called when a file is modified
* outside the CGI editor.
- *
+ *
* Parameters :
* 1 : csp = Current client state (buffers, headers, etc...)
* 2 : rsp = http_response data structure for output
* CGI Parameters : none
*
* Returns : JB_ERR_OK on success
- * JB_ERR_MEMORY on out-of-memory error.
+ * JB_ERR_MEMORY on out-of-memory error.
*
*********************************************************************/
jb_err cgi_error_modified(struct client_state *csp,
*
* Description : CGI function that is called when a file cannot
* be parsed by the CGI editor.
- *
+ *
* Parameters :
* 1 : csp = Current client state (buffers, headers, etc...)
* 2 : rsp = http_response data structure for output
* CGI Parameters : none
*
* Returns : JB_ERR_OK on success
- * JB_ERR_MEMORY on out-of-memory error.
+ * JB_ERR_MEMORY on out-of-memory error.
*
*********************************************************************/
jb_err cgi_error_parse(struct client_state *csp,
*
* Description : CGI function that is called when a file cannot be
* opened by the CGI editor.
- *
+ *
* Parameters :
* 1 : csp = Current client state (buffers, headers, etc...)
* 2 : rsp = http_response data structure for output
* CGI Parameters : none
*
* Returns : JB_ERR_OK on success
- * JB_ERR_MEMORY on out-of-memory error.
+ * JB_ERR_MEMORY on out-of-memory error.
*
*********************************************************************/
jb_err cgi_error_file(struct client_state *csp,
*
* Description : CGI function that is called if the parameters
* (query string) for a CGI were wrong.
- *
+ *
* Parameters :
* 1 : csp = Current client state (buffers, headers, etc...)
* 2 : rsp = http_response data structure for output
* CGI Parameters : none
*
* Returns : JB_ERR_OK on success
- * JB_ERR_MEMORY on out-of-memory error.
+ * JB_ERR_MEMORY on out-of-memory error.
*
*********************************************************************/
jb_err cgi_error_disabled(struct client_state *csp,
}
return err;
}
-
+
err = template_load(csp, &url_template, "edit-actions-list-url");
if (err)
{
snprintf(buf, 50, "%d", line_number);
err = map(section_exports, "sectionid", 1, buf, 1);
- err = err || map(section_exports, "actions", 1,
+ err = err || map(section_exports, "actions", 1,
actions_to_html(cur_line->data.action), 0);
if ((cur_line->next != NULL) && (cur_line->next->type == FILE_LINE_URL))
snprintf(buf, 50, "%d", url_1_2);
err = err || map(url_exports, "url-1-2", 1, buf, 1);
- err = err || map(url_exports, "url", 1,
+ err = err || map(url_exports, "url", 1,
html_encode(cur_line->unprocessed), 0);
if (err)
struct http_response *rsp,
const struct map *parameters)
{
- int sectionid;
+ unsigned sectionid;
char * actiontext;
char * newtext;
int len;
-const char errlog_rcs[] = "$Id: errlog.c,v 1.19 2001/09/13 20:08:06 jongfoster Exp $";
+const char errlog_rcs[] = "$Id: errlog.c,v 1.20 2001/09/16 23:04:34 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/errlog.c,v $
*
* Revisions :
* $Log: errlog.c,v $
+ * Revision 1.20 2001/09/16 23:04:34 jongfoster
+ * Fixing a warning
+ *
* Revision 1.19 2001/09/13 20:08:06 jongfoster
* Adding support for LOG_LEVEL_CGI
*
#include <stdarg.h>
#include <string.h>
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(__OS2__)
#include <unistd.h>
-#endif /* ndef _WIN32 */
+#endif /* !defined(_WIN32) && !defined(__OS2__) */
#include <errno.h>
+#include <assert.h>
#ifdef FEATURE_PTHREAD
#include <pthread.h>
#endif /* def FEATURE_PTHREAD */
#endif /* ndef _WIN_CONSOLE */
#endif /* def _WIN32 */
+#ifdef __OS2__
+#define INCL_DOS
+#include <os2.h>
+#endif
+
#include "errlog.h"
#include "project.h"
void log_error(int loglevel, char *fmt, ...)
{
va_list ap;
- char outbuf[BUFFER_SIZE];
+ char *outbuf= NULL;
char * src = fmt;
int outc = 0;
long this_thread = 1; /* was: pthread_t this_thread;*/
+#ifdef __OS2__
+ PTIB ptib;
+ APIRET ulrc;
+#endif /* __OS2__ */
#if defined(_WIN32) && !defined(_WIN_CONSOLE)
/*
/* FIXME get current thread id */
#ifdef FEATURE_PTHREAD
this_thread = (long)pthread_self();
+#elif __OS2__
+
+ ulrc = DosGetInfoBlocks(&ptib, NULL);
+ if (ulrc == 0)
+ this_thread = ptib -> tib_ptib2 -> tib2_ultid;
#endif /* def FEATURE_PTHREAD */
+ outbuf = (char*)malloc(BUFFER_SIZE);
+ assert(outbuf);
switch (loglevel)
{
case LOG_LEVEL_ERROR:
tab-width: 3
end:
*/
-
-const char filters_rcs[] = "$Id: filters.c,v 1.37 2001/10/22 15:33:56 david__schmidt Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.38 2001/10/23 21:32:33 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/filters.c,v $
* IJBSWA team. http://ijbswa.sourceforge.net
*
* Based on the Internet Junkbuster originally written
- * by and Copyright (C) 1997 Anonymous Coders and
+ * by and Copyright (C) 1997 Anonymous Coders and
* Junkbusters Corporation. http://www.junkbusters.com
*
- * This program is free software; you can redistribute it
+ * This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
*
* Revisions :
* $Log: filters.c,v $
+ * Revision 1.38 2001/10/23 21:32:33 jongfoster
+ * Adding error-checking to selected functions
+ *
* Revision 1.37 2001/10/22 15:33:56 david__schmidt
* Special-cased OS/2 out of the Netscape-abort-on-404-in-js problem in
* filters.c. Added a FIXME in front of the offending code. I'll gladly
#include <assert.h>
#ifndef _WIN32
+#ifndef __OS2__
#include <unistd.h>
+#endif /* ndef __OS2__ */
#include <netinet/in.h>
#else
#include <winsock2.h>
-#endif
+#endif /* ndef _WIN32 */
+
+#ifdef __OS2__
+#include <utils.h>
+#endif /* def __OS2__ */
#include "project.h"
#include "filters.h"
{
*next++ = '\0';
}
-
+
/*
* Loop through all items, checking for match
*/
free(portlist_copy);
return(1);
}
-
- }
+
+ }
/*
* Jump to next item
*next++ = '\0';
}
}
-
+
free(portlist_copy);
return 0;
#endif /* def FEATURE_IMAGE_BLOCKING */
struct http_response *rsp;
- /*
+ /*
* If it's not blocked, don't block it ;-)
*/
if ((csp->action->flags & ACTION_BLOCK) == 0)
return NULL;
}
- /*
+ /*
* Else, prepare a response
*/
if (NULL == (rsp = alloc_http_response()))
return cgi_error_memory();
}
}
- }
+ }
else
#endif /* def FEATURE_IMAGE_BLOCKING */
- /*
+ /*
* Else, generate an HTML "blocked" message:
*/
{
jb_err err;
struct map * exports;
-
+
/* FIXME */
#ifdef __EMX__
/*
* what the csp->http->user_agent is (yet). So we can't use
* it to decide if we should work around the NS bug or not.
*/
- rsp->status = strdup("200 Request for blocked URL");
+ rsp->status = strdup("200 Request for blocked URL");
#else
/*
* Workaround for stupid Netscape bug which prevents
&& !strstr(csp->http->user_agent, "compatible")
&& !strstr(csp->http->user_agent, "Opera"))
{
- rsp->status = strdup("200 Request for blocked URL");
+ rsp->status = strdup("200 Request for blocked URL");
}
else
{
- rsp->status = strdup("404 Request for blocked URL");
+ rsp->status = strdup("404 Request for blocked URL");
}
#endif /* __EMX__ */
if (rsp->status == NULL)
return NULL;
}
- /*
+ /*
* Else, prepare a response:
*/
if (NULL == (rsp = alloc_http_response()))
return cgi_error_memory();
}
- /*
+ /*
* Export the host, port, and referrer information
*/
err = map(exports, "hostport", 1, csp->http->hostport, 1)
p = q = csp->http->path;
log_error(LOG_LEVEL_REDIRECTS, "checking path for redirects: %s", p);
- /*
+ /*
* find the last URL encoded in the request
*/
while ((p = strstr(p, "http://")))
q = p++;
}
- /*
+ /*
* if there was any, generate and return a HTTP redirect
*/
if (q != csp->http->path)
* using either the info from a previous +image action
* or, #ifdef FEATURE_IMAGE_DETECT_MSIE, the info from
* the browser's accept header.
- *
+ *
* Parameters :
* 1 : csp = Current client state (buffers, headers, etc...)
*
int is_imageurl(struct client_state *csp)
{
#ifdef FEATURE_IMAGE_DETECT_MSIE
- if ((csp->accept_types
+ if ((csp->accept_types
& (ACCEPT_TYPE_IS_MSIE|ACCEPT_TYPE_MSIE_IMAGE|ACCEPT_TYPE_MSIE_HTML))
== (ACCEPT_TYPE_IS_MSIE|ACCEPT_TYPE_MSIE_IMAGE))
{
return 1;
}
- else if ((csp->accept_types
+ else if ((csp->accept_types
& (ACCEPT_TYPE_IS_MSIE|ACCEPT_TYPE_MSIE_IMAGE|ACCEPT_TYPE_MSIE_HTML))
== (ACCEPT_TYPE_IS_MSIE|ACCEPT_TYPE_MSIE_HTML))
{
* Function : pcrs_filter_response
*
* Description : Apply all the pcrs jobs from the joblist (re_filterfile)
- * to the text buffer that's been accumulated in
+ * to the text buffer that's been accumulated in
* csp->iob->buf and set csp->content_length to the modified
* size and raise the CSP_FLAG_MODIFIED flag if appropriate.
*
*
* Returns : a pointer to the (newly allocated) modified buffer.
* or NULL in case something went wrong
- *
+ *
*********************************************************************/
char *pcrs_filter_response(struct client_state *csp)
{
log_error(LOG_LEVEL_RE_FILTER, " produced %d hits (new size %d).", hits, size);
- /*
+ /*
* If there were no hits, destroy our copy and let
* chat() use the original in csp->iob
*/
*
* Function : gif_deanimate_response
*
- * Description : Deanimate the GIF image that has been accumulated in
+ * Description : Deanimate the GIF image that has been accumulated in
* csp->iob->buf, set csp->content_length to the modified
* size and raise the CSP_FLAG_MODIFIED flag.
*
*
* Returns : a pointer to the (newly allocated) modified buffer.
* or NULL in case something went wrong.
- *
+ *
*********************************************************************/
char *gif_deanimate_response(struct client_state *csp)
{
free(in);
free(out);
return(p);
- }
+ }
}
* Returns : The new size, i.e. the number of bytes from buffer which
* are occupied by the stripped body, or 0 in case something
* went wrong
- *
+ *
*********************************************************************/
int remove_chunked_transfer_coding(char *buffer, const size_t size)
{
}
newsize += chunksize;
from_p += 2;
-
+
memmove(to_p, from_p, (size_t) chunksize);
to_p = buffer + newsize;
from_p += chunksize + 2;
* Returns : N/A
*
*********************************************************************/
-void url_actions(struct http_request *http,
+void url_actions(struct http_request *http,
struct client_state *csp)
{
struct file_list *fl;
* Returns : N/A
*
*********************************************************************/
-void apply_url_actions(struct current_action_spec *action,
- struct http_request *http,
+void apply_url_actions(struct current_action_spec *action,
+ struct http_request *http,
struct url_actions *b)
{
struct url_spec url[1];
* them).
*
* FIXME: Returning a structure is horribly inefficient, please can
- * this structure take a (struct url_spec * dest)
+ * this structure take a (struct url_spec * dest)
* pointer instead?
*
*********************************************************************/
*
* Function : simple_domaincmp
*
- * Description : Domain-wise Compare fqdn's. The comparison is
+ * Description : Domain-wise Compare fqdn's. The comparison is
* both left- and right-anchored. The individual
* domain names are compared with simplematch().
* This is only used by domaincmp.
-const char gateway_rcs[] = "$Id: gateway.c,v 1.7 2001/09/12 17:58:26 steudten Exp $";
+const char gateway_rcs[] = "$Id: gateway.c,v 1.8 2001/09/13 20:10:12 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/gateway.c,v $
* IJBSWA team. http://ijbswa.sourceforge.net
*
* Based on the Internet Junkbuster originally written
- * by and Copyright (C) 1997 Anonymous Coders and
+ * by and Copyright (C) 1997 Anonymous Coders and
* Junkbusters Corporation. http://www.junkbusters.com
*
- * This program is free software; you can redistribute it
+ * This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
*
* Revisions :
* $Log: gateway.c,v $
+ * Revision 1.8 2001/09/13 20:10:12 jongfoster
+ * Fixing missing #include under Windows
+ *
* Revision 1.7 2001/09/12 17:58:26 steudten
*
* add #include <string.h>
#include <netdb.h>
#endif /* def __BEOS__ */
+#ifdef __OS2__
+#include <utils.h>
+#endif /* def __OS2__ */
+
#include "project.h"
#include "jcc.h"
#include "errlog.h"
const char gateway_h_rcs[] = GATEWAY_H_VERSION;
-static int socks4_connect(const struct forward_spec * fwd,
+static int socks4_connect(const struct forward_spec * fwd,
const char * target_host,
int target_port,
struct client_state *csp);
* Returns : -1 => failure, else it is the socket file descriptor.
*
*********************************************************************/
-int forwarded_connect(const struct forward_spec * fwd,
- struct http_request *http,
+int forwarded_connect(const struct forward_spec * fwd,
+ struct http_request *http,
struct client_state *csp)
{
const char * dest_host;
* Returns : -1 => failure, else a socket file descriptor.
*
*********************************************************************/
-static int socks4_connect(const struct forward_spec * fwd,
+static int socks4_connect(const struct forward_spec * fwd,
const char * target_host,
int target_port,
struct client_state *csp)
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.17 2001/09/13 20:11:46 jongfoster Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.18 2001/09/21 23:02:02 david__schmidt Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
*
* Revisions :
* $Log: jbsockets.c,v $
+ * Revision 1.18 2001/09/21 23:02:02 david__schmidt
+ * Cleaning up 2 compiler warnings on OS/2.
+ *
* Revision 1.17 2001/09/13 20:11:46 jongfoster
* Fixing 2 compiler warnings under Win32
*
#else
+#ifndef __OS2__
#include <unistd.h>
+#endif
#include <sys/time.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#ifndef __BEOS__
#include <netinet/tcp.h>
+#ifndef __OS2__
#include <arpa/inet.h>
+#endif
#else
#include <socket.h>
#endif
-#ifdef __EMX__
+#if defined(__EMX__) || defined (__OS2__)
#include <sys/select.h> /* OS/2/EMX needs a little help with select */
+#include <nerrno.h>
#endif
#endif
if (block_acl(dst, csp))
{
+#ifdef __OS2__
+ errno = SOCEPERM;
+#else
errno = EPERM;
+#endif
return(-1);
}
#endif /* def FEATURE_ACL */
}
#endif /* def TCP_NODELAY */
-#if !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA)
+#if !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) && !defined(__OS2__)
if ((flags = fcntl(fd, F_GETFL, 0)) != -1)
{
flags |= O_NDELAY;
fcntl(fd, F_SETFL, flags);
}
-#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) */
+#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) && !defined(__OS2__) */
while (connect(fd, (struct sockaddr *) & inaddr, sizeof inaddr) == -1)
{
#ifdef _WIN32
if (errno == WSAEINPROGRESS)
+#elif __OS2__
+ if (sock_errno() == EINPROGRESS)
#else /* ifndef _WIN32 */
if (errno == EINPROGRESS)
-#endif /* ndef _WIN32 */
+#endif /* ndef _WIN32 || __OS2__ */
{
break;
}
+#ifdef __OS2__
+ if (sock_errno() != EINTR)
+#else
if (errno != EINTR)
+#endif /* __OS2__ */
{
close_socket(fd);
return(-1);
}
}
-#if !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA)
+#if !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) && !defined(__OS2__)
if (flags != -1)
{
flags &= ~O_NDELAY;
fcntl(fd, F_SETFL, flags);
}
-#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) */
+#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) && !defined(__OS2__) */
/* wait for connection to complete */
FD_ZERO(&wfds);
log_error(LOG_LEVEL_LOG, "%N", len, buf);
-#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA)
+#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA) || defined(__OS2__)
return( send(fd, buf, len, 0));
#else
return( write(fd, buf, len));
return(0);
}
-#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA)
+#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA) || defined(__OS2__)
return( recv(fd, buf, len, 0));
#else
return( read(fd, buf, len));
closesocket(fd);
#elif defined(AMIGA)
CloseSocket(fd);
+#elif defined(__OS2__)
+ soclose(fd);
#else
close(fd);
#endif
-const char jcc_rcs[] = "$Id: jcc.c,v 1.48 2001/10/10 19:56:46 jongfoster Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.49 2001/10/23 21:41:35 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
*
- * Purpose : Main file. Contains main() method, main loop, and
+ * Purpose : Main file. Contains main() method, main loop, and
* the main connection-handling function.
*
* Copyright : Written by and Copyright (C) 2001 the SourceForge
* IJBSWA team. http://ijbswa.sourceforge.net
*
* Based on the Internet Junkbuster originally written
- * by and Copyright (C) 1997 Anonymous Coders and
+ * by and Copyright (C) 1997 Anonymous Coders and
* Junkbusters Corporation. http://www.junkbusters.com
*
- * This program is free software; you can redistribute it
+ * This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
*
* Revisions :
* $Log: jcc.c,v $
+ * Revision 1.49 2001/10/23 21:41:35 jongfoster
+ * Added call to initialize the (statically-allocated of course)
+ * "out of memory" CGI response.
+ *
* Revision 1.48 2001/10/10 19:56:46 jongfoster
* Moving some code that wasn't cookie-related out of an #ifdef
* FEATURE_COOKIE_JAR
#else /* ifndef _WIN32 */
+# if !defined (__OS2__)
# include <unistd.h>
-# include <sys/time.h>
# include <sys/wait.h>
+# endif /* ndef __OS2__ */
+# include <sys/time.h>
# include <sys/stat.h>
# include <signal.h>
# include <OS.h> /* declarations for threads and stuff. */
# endif
-# ifdef __EMX__
+# if defined(__EMX__) || defined(__OS2__)
# include <sys/select.h> /* OS/2/EMX needs a little help with select */
# endif
+# ifdef __OS2__
+#define INCL_DOS
+# include <os2.h>
+#define bzero(B,N) memset(B,0x00,n)
+# endif
# ifndef FD_ZERO
# include <select.h>
#define sleep(N) Sleep(((N) * 1000))
#endif
+#ifdef __OS2__
+#define sleep(N) DosSleep(((N) * 100))
+#endif
+
/* The vanilla wafer. */
static const char VANILLA_WAFER[] =
*
* Description : Once a connection to the client has been accepted,
* this function is called (via serve()) to handle the
- * main business of the communication. When this
+ * main business of the communication. When this
* function returns, the caller must close the client
* socket handle.
*
{
/*
* This next lines are a little ugly, but they simplifies the if statements
- * below. Basically if TOGGLE, then we want the if to test if the
+ * below. Basically if TOGGLE, then we want the if to test if the
* CSP_FLAG_TOGGLED_ON flag ist set, else we don't. And if FEATURE_FORCE_LOAD,
* then we want the if to test for CSP_FLAG_FORCED , else we don't
*/
# define IS_TOGGLED_ON_AND
#endif /* ndef FEATURE_TOGGLE */
#ifdef FEATURE_FORCE_LOAD
-# define IS_NOT_FORCED_AND !(csp->flags & CSP_FLAG_FORCED) &&
+# define IS_NOT_FORCED_AND !(csp->flags & CSP_FLAG_FORCED) &&
#else /* ifndef FEATURE_FORCE_LOAD */
# define IS_NOT_FORCED_AND
#endif /* def FEATURE_FORCE_LOAD */
int gif_deanimate; /* bool, 1==will deanimate gifs */
/* Function that does the content filtering for the current request */
- char *(*content_filter)() = NULL;
+ char *(*content_filter)() = NULL;
/* Skeleton for HTTP response, if we should intercept the request */
struct http_response *rsp;
{
continue; /* more to come! */
}
-
+
#ifdef FEATURE_FORCE_LOAD
/* If this request contains the FORCE_PREFIX,
* better get rid of it now and set the force flag --oes
strclean(req, FORCE_PREFIX);
log_error(LOG_LEVEL_FORCE, "Enforcing request \"%s\".\n", req);
csp->flags |= CSP_FLAG_FORCED;
- }
+ }
#endif /* def FEATURE_FORCE_LOAD */
* full orininal URL (w/url)
* Note that the path and/or the HTTP version may
* have been altered by now.
- *
+ *
* connect = Open a socket to the host:port of the server
* and short-circuit server and client socket.
*
* parent's). After sending the request to the parent, we simply
* tunnel.
*
- * here's the matrix:
+ * here's the matrix:
* SSL
* 0 1
* +--------+--------+
*
*/
- /*
+ /*
* Determine the actions for this URL
*/
#ifdef FEATURE_TOGGLE
*/
if(http->ssl)
{
- if( ( !(csp->action->flags & ACTION_LIMIT_CONNECT) && csp->http->port != 443)
+ if( ( !(csp->action->flags & ACTION_LIMIT_CONNECT) && csp->http->port != 443)
|| (csp->action->flags & ACTION_LIMIT_CONNECT
&& !match_portlist(csp->action->string[ACTION_STRING_LIMIT_CONNECT], csp->http->port)) )
{
strcpy(buf, CFORBIDDEN);
write_socket(csp->cfd, buf, strlen(buf));
-
+
log_error(LOG_LEVEL_CONNECT, "Denying suspicious CONNECT request from %s", csp->ip_addr_str);
log_error(LOG_LEVEL_CLF, "%s - - [%T] \" \" 403 0", csp->ip_addr_str);
return;
}
}
-
+
/*
* Downgrade http version from 1.1 to 1.0 if +downgrade
* (Re)build the HTTP request for non-SSL requests.
* If forwarding, use the whole URL, else, use only the path.
*/
- if (http->ssl == 0)
- {
+ if (http->ssl == 0)
+ {
freez(http->cmd);
http->cmd = strsav(http->cmd, http->gpc);
/* We have a request. */
- /*
+ /*
* Now, check to see if we need to intercept it, i.e.
* If
*/
-
+
if (
/* a CGI call was detected and answered */
- (NULL != (rsp = dispatch_cgi(csp)))
+ (NULL != (rsp = dispatch_cgi(csp)))
/* or we are enabled and... */
|| (IS_ENABLED_AND (
/* ..or a fast redirect kicked in */
#ifdef FEATURE_FAST_REDIRECTS
- || (((csp->action->flags & ACTION_FAST_REDIRECTS) != 0) &&
+ || (((csp->action->flags & ACTION_FAST_REDIRECTS) != 0) &&
(NULL != (rsp = redirect_url(csp))))
#endif /* def FEATURE_FAST_REDIRECTS */
))
/* Write the answer to the client */
if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
|| (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
- {
+ {
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
}
/* Log (FIXME: All intercept reasons apprear as "crunch" with Status 200) */
log_error(LOG_LEVEL_GPC, "%s%s crunch!", http->hostport, http->path);
- log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 3", csp->ip_addr_str, http->cmd);
+ log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 3", csp->ip_addr_str, http->cmd);
/* Clean up and return */
free_http_response(rsp);
{
rsp = error_response(csp, "no-such-domain", errno);
- log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 404 0",
+ log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 404 0",
csp->ip_addr_str, http->cmd);
}
else
{
rsp = error_response(csp, "connect-failed", errno);
- log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0",
+ log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0",
csp->ip_addr_str, http->cmd);
}
{
if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
|| (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
- {
+ {
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
}
}
log_error(LOG_LEVEL_CONNECT, "write header to: %s failed: %E",
http->hostport);
- log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0",
- csp->ip_addr_str, http->cmd);
+ log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0",
+ csp->ip_addr_str, http->cmd);
rsp = error_response(csp, "connect-failed", errno);
{
if ((write_socket(csp->cfd, rsp->head, n) != n)
|| (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
- {
+ {
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
}
}
* so just send the "connect succeeded" message to the
* client, flush the rest, and get out of the way.
*/
- log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 2\n",
- csp->ip_addr_str, http->cmd);
+ log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 2\n",
+ csp->ip_addr_str, http->cmd);
if (write_socket(csp->cfd, CSUCCEED, sizeof(CSUCCEED)-1) < 0)
{
{
log_error(LOG_LEVEL_ERROR, "read from: %s failed: %E", http->host);
- log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0",
- csp->ip_addr_str, http->cmd);
+ log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0",
+ csp->ip_addr_str, http->cmd);
rsp = error_response(csp, "connect-failed", errno);
{
if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
|| (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
- {
+ {
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
}
}
*/
if (n == 0)
{
-
+
if (server_body || http->ssl)
{
/*
}
/*
- * This is NOT the body, so
+ * This is NOT the body, so
* Let's pretend the server just sent us a blank line.
*/
n = sprintf(buf, "\r\n");
{
if (content_filter)
{
- add_to_iob(csp, buf, n);
+ add_to_iob(csp, buf, n);
/*
* If the buffer limit will be reached on the next read,
if (csp->iob->eod - csp->iob->buf + BUFFER_SIZE > csp->config->buffer_limit)
{
log_error(LOG_LEVEL_ERROR, "Buffer size limit reached! Flushing and stepping back.");
-
+
hdr = sed(server_patterns, add_server_headers, csp);
n = strlen(hdr);
byte_count += n;
return; /* huh? we should never get here */
}
- log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 %d",
- csp->ip_addr_str, http->cmd, byte_count);
+ log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 %d",
+ csp->ip_addr_str, http->cmd, byte_count);
}
* any load fails, and can't bind port.
*
* Else main never returns, the process must be signaled
- * to terminate execution. Or, on Windows, use the
+ * to terminate execution. Or, on Windows, use the
* "File", "Exit" menu option.
*
*********************************************************************/
#endif
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(__OS2__)
signal(SIGPIPE, SIG_IGN);
signal(SIGCHLD, SIG_IGN);
{
log_error(LOG_LEVEL_FATAL, "can't bind %s:%d: %E "
"- There may be another junkbuster or some other "
- "proxy running on port %d",
- (NULL != config->haddr) ? config->haddr : "INADDR_ANY",
+ "proxy running on port %d",
+ (NULL != config->haddr) ? config->haddr : "INADDR_ANY",
config->hport, config->hport
);
/* shouldn't get here */
while (FOREVER)
{
-#if !defined(FEATURE_PTHREAD) && !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA)
+#if !defined(FEATURE_PTHREAD) && !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) && !defined(__OS2__)
while (waitpid(-1, NULL, WNOHANG) > 0)
{
/* zombie children */
{
log_error(LOG_LEVEL_FATAL, "can't bind %s:%d: %E "
"- There may be another junkbuster or some other "
- "proxy running on port %d",
- (NULL != config->haddr) ? config->haddr : "INADDR_ANY",
+ "proxy running on port %d",
+ (NULL != config->haddr) ? config->haddr : "INADDR_ANY",
config->hport, config->hport
);
/* shouldn't get here */
#ifdef AMIGA
if(!childs)
{
- exit(1);
+ exit(1);
}
#endif
freez(csp);
csp);
#endif
+#if defined(__OS2__) && !defined(SELECTED_ONE_OPTION)
+#define SELECTED_ONE_OPTION
+ child_id = _beginthread(
+ serve,
+ NULL,
+ 64 * 1024,
+ csp);
+#endif
+
#if defined(__BEOS__) && !defined(SELECTED_ONE_OPTION)
#define SELECTED_ONE_OPTION
{
-const char killpopup_rcs[] = "$Id: killpopup.c,v 1.10 2001/09/22 16:34:44 jongfoster Exp $";
+const char killpopup_rcs[] = "$Id: killpopup.c,v 1.11 2001/10/07 15:42:41 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/killpopup.c,v $
* IJBSWA team. http://ijbswa.sourceforge.net
*
* Based on the Internet Junkbuster originally written
- * by and Copyright (C) 1997 Anonymous Coders and
+ * by and Copyright (C) 1997 Anonymous Coders and
* Junkbusters Corporation. http://www.junkbusters.com
*
- * This program is free software; you can redistribute it
+ * This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
*
* Revisions :
* $Log: killpopup.c,v $
+ * Revision 1.11 2001/10/07 15:42:41 oes
+ * filter_popups now gets a csp pointer so it can raise the new
+ * CSP_FLAG_MODIFIED flag.
+ *
* Revision 1.10 2001/09/22 16:34:44 jongfoster
* Removing unneeded #includes
*
#include <sys/stat.h>
#include <ctype.h>
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(__OS2__)
#include <unistd.h>
#endif
csp->flags |= CSP_FLAG_MODIFIED;
}
}
-
+
while ((popup = strstr( buff, ".resizeTo(" )) != NULL)
{
if ( popup )
-const char list_rcs[] = "$Id: list.c,v 1.10 2001/09/16 17:30:24 jongfoster Exp $";
+const char list_rcs[] = "$Id: list.c,v 1.11 2001/10/23 21:21:03 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/list.c,v $
* IJBSWA team. http://ijbswa.sourceforge.net
*
* Based on the Internet Junkbuster originally written
- * by and Copyright (C) 1997 Anonymous Coders and
+ * by and Copyright (C) 1997 Anonymous Coders and
* Junkbusters Corporation. http://www.junkbusters.com
*
- * This program is free software; you can redistribute it
+ * This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
*
* Revisions :
* $Log: list.c,v $
+ * Revision 1.11 2001/10/23 21:21:03 jongfoster
+ * New error handling - error codes are now jb_errs, not ints.
+ * Changed the way map() handles out-of-memory, to dramatically
+ * reduce the amount of error-checking clutter needed.
+ *
* Revision 1.10 2001/09/16 17:30:24 jongfoster
* Fixing a compiler warning.
*
#endif
#include <string.h>
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(__OS2__)
#include <unistd.h>
#endif
* then pass it to this function.
* (Implementation note: Rather than calling this
* function, you can also just memset the memory to
- * zero, e.g. if you have a larger structure you
- * want to initialize quickly. However, that isn't
+ * zero, e.g. if you have a larger structure you
+ * want to initialize quickly. However, that isn't
* really good design.)
*
* Parameters :
* calling list_init().
*
* (Implementation note: You *can* reuse the_list
- * without calling list_init(), but please don't.
+ * without calling list_init(), but please don't.
* If you want to remove all entries from a list
- * and still have a usable list, then use
+ * and still have a usable list, then use
* list_remove_all().)
*
* Parameters :
for (cur_entry = the_list->first; cur_entry ; cur_entry = next_entry)
{
next_entry = cur_entry->next;
- freez((char *)cur_entry->str);
+ freez(cur_entry->str);
free(cur_entry);
}
* Description : Check that a string list is valid. The intended
* usage is "assert(list_is_valid(the_list))".
* Currently this checks that "the_list->last"
- * is correct, and that the list dosn't contain
+ * is correct, and that the list dosn't contain
* circular references. It is likely to crash if
* it's passed complete garbage.
*
if (cur_entry->str)
{
/*
- * Just check that this string can be accessed - i.e. it's a valid
+ * Just check that this string can be accessed - i.e. it's a valid
* pointer.
*/
strlen(cur_entry->str);
* 2 : str = string to add to the list (maybe NULL)
*
* Returns : JB_ERR_OK on success
- * JB_ERR_MEMORY on out-of-memory error.
+ * JB_ERR_MEMORY on out-of-memory error.
* On error, the_list will be unchanged.
*
*********************************************************************/
* 2 : str = string to add to the list (maybe NULL)
*
* Returns : JB_ERR_OK on success
- * JB_ERR_MEMORY on out-of-memory error.
+ * JB_ERR_MEMORY on out-of-memory error.
* On error, the_list will be unchanged.
*
*********************************************************************/
}
}
/* else { cur->str = NULL; } - implied by zalloc */
-
+
cur->next = the_list->first;
the_list->first = cur;
* Description : Append a string into a specified string list,
* if & only if it's not there already.
* If the num_significant_chars argument is nonzero,
- * only compare up to the nth character.
+ * only compare up to the nth character.
*
* Parameters :
* 1 : the_list = pointer to list
* for uniqueness test, or 0 to require an exact match.
*
* Returns : JB_ERR_OK on success
- * JB_ERR_MEMORY on out-of-memory error.
+ * JB_ERR_MEMORY on out-of-memory error.
* On error, the_list will be unchanged.
* "Success" does not indicate whether or not the
* item was already in the list.
* 3 : value = HTTP header value (e.g. "text/html")
*
* Returns : JB_ERR_OK on success
- * JB_ERR_MEMORY on out-of-memory error.
+ * JB_ERR_MEMORY on out-of-memory error.
* On error, the_list will be unchanged.
* "Success" does not indicate whether or not the
* header was already in the list.
* Description : Remove all entries from a list. On return, the_list
* is a valid, empty list. Note that this is similar
* to destroy_list(), but the difference is that this
- * function guarantees that the list structure is still
+ * function guarantees that the list structure is still
* valid after the call.
*
* Parameters :
for (cur_entry = the_list->first; cur_entry ; cur_entry = next_entry)
{
next_entry = cur_entry->next;
- freez((char *)cur_entry->str);
+ freez(cur_entry->str);
free(cur_entry);
}
* 1 : src = pointer to source list for copy.
*
* Returns : JB_ERR_OK on success
- * JB_ERR_MEMORY on out-of-memory error.
+ * JB_ERR_MEMORY on out-of-memory error.
* On error, dest will be empty.
*
*********************************************************************/
* 2 : src = pointer to source for merge.
*
* Returns : JB_ERR_OK on success
- * JB_ERR_MEMORY on out-of-memory error.
+ * JB_ERR_MEMORY on out-of-memory error.
* On error, some (but not all) of src might have
* been copied into dest.
*
{
assert(the_list);
assert(list_is_valid(the_list));
-
+
return (the_list->first == NULL);
}
return;
}
- for (cur_entry = the_map->first; cur_entry != NULL; cur_entry = next_entry)
+ for (cur_entry = the_map->first; cur_entry != NULL; cur_entry = next_entry)
{
- freez((char *)cur_entry->name);
- freez((char *)cur_entry->value);
+ freez(cur_entry->name);
+ freez(cur_entry->value);
next_entry = cur_entry->next;
free(cur_entry);
* err = map(mymap, "xyz", 1, html_encode(somestring), 0);
*
* err will be set to JB_ERR_MEMORY if either call runs
- * out-of-memory. Without these features, you would
- * need to check the return value of html_encode in the
- * above example for NULL, which (at least) doubles the
+ * out-of-memory. Without these features, you would
+ * need to check the return value of html_encode in the
+ * above example for NULL, which (at least) doubles the
* amount of error-checking code needed.
*
* Parameters :
* 5 : value_needs_copying = flag set if a copy of value should be used
*
* Returns : JB_ERR_OK on success
- * JB_ERR_MEMORY on out-of-memory error.
+ * JB_ERR_MEMORY on out-of-memory error.
*
*********************************************************************/
jb_err map(struct map *the_map,
-const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.23 2001/10/07 15:36:00 oes Exp $";
+const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.24 2001/10/23 21:40:30 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
*
* Purpose : Loads settings from the configuration file into
- * global variables. This file contains both the
+ * global variables. This file contains both the
* routine to load the configuration and the global
* variables it writes to.
*
* IJBSWA team. http://ijbswa.sourceforge.net
*
* Based on the Internet Junkbuster originally written
- * by and Copyright (C) 1997 Anonymous Coders and
+ * by and Copyright (C) 1997 Anonymous Coders and
* Junkbusters Corporation. http://www.junkbusters.com
*
- * This program is free software; you can redistribute it
+ * This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
*
* Revisions :
* $Log: loadcfg.c,v $
+ * Revision 1.24 2001/10/23 21:40:30 jongfoster
+ * Added support for enable-edit-actions and enable-remote-toggle config
+ * file options.
+ *
* Revision 1.23 2001/10/07 15:36:00 oes
* Introduced new config option "buffer-limit"
*
#else /* ifndef _WIN32 */
+#ifndef __OS2__
# include <unistd.h>
-# include <sys/time.h>
# include <sys/wait.h>
+#endif
+# include <sys/time.h>
# include <sys/stat.h>
# include <signal.h>
cur_fwd = next_fwd;
}
config->forward = NULL;
-
+
#ifdef FEATURE_COOKIE_JAR
if ( NULL != config->jar )
{
}
#endif /* def FEATURE_COOKIE_JAR */
- freez((char *)config->confdir);
- freez((char *)config->logdir);
+ freez(config->confdir);
+ freez(config->logdir);
- freez((char *)config->haddr);
- freez((char *)config->logfile);
+ freez(config->haddr);
+ freez(config->logfile);
- freez((char *)config->actions_file);
- freez((char *)config->admin_address);
- freez((char *)config->proxy_info_url);
- freez((char *)config->proxy_args);
+ freez(config->actions_file);
+ freez(config->admin_address);
+ freez(config->proxy_info_url);
+ freez(config->proxy_args);
#ifdef FEATURE_COOKIE_JAR
- freez((char *)config->jarfile);
+ freez(config->jarfile);
#endif /* def FEATURE_COOKIE_JAR */
- freez((char *)config->re_filterfile);
+ freez(config->re_filterfile);
}
* Description : Load the config file and all parameters.
*
* Parameters :
- * 1 : csp = Client state (the config member will be
+ * 1 : csp = Client state (the config member will be
* filled in by this function).
*
* Returns : 0 => Ok, everything else is an error.
/*
* This is backwards from how it's usually done.
- * Following the usual pattern, "fs" would be stored in a member
+ * Following the usual pattern, "fs" would be stored in a member
* variable in "csp", and then we'd access "config" from "fs->f",
- * using a cast. However, "config" is used so often that a
+ * using a cast. However, "config" is used so often that a
* cast each time would be very ugly, and the extra indirection
* would waste CPU cycles. Therefore we store "config" in
* "csp->config", and "fs" in "csp->config->config_file_list".
* In confdir by default
****************************************************************************/
case hash_actions_file :
- freez((char *)config->actions_file);
+ freez(config->actions_file);
config->actions_file = make_path(config->confdir, arg);
continue;
* admin-address email-address
****************************************************************************/
case hash_admin_address :
- freez((char *)config->admin_address);
+ freez(config->admin_address);
config->admin_address = strdup(arg);
- continue;
+ continue;
/****************************************************************************
* buffer-limit n
****************************************************************************/
case hash_buffer_limit :
config->buffer_limit = (size_t) 1024 * atoi(arg);
- continue;
+ continue;
/****************************************************************************
* confdir directory-name
****************************************************************************/
case hash_confdir :
- freez((char *)config->confdir);
+ freez(config->confdir);
config->confdir = strdup(arg);
- continue;
+ continue;
/****************************************************************************
* debug n
* actions file, the last match wins. However, the internal
* implementations are different: The actions file is stored
* in the same order as the file, and scanned completely.
- * With the ACL, we reverse the order as we load it, then
+ * With the ACL, we reverse the order as we load it, then
* when we scan it we stop as soon as we get a match.
*/
cur_acl->next = config->acl;
/* Add to list. */
cur_fwd->next = config->forward;
config->forward = cur_fwd;
-
+
continue;
/****************************************************************************
/* Add to list. */
cur_fwd->next = config->forward;
config->forward = cur_fwd;
-
+
continue;
/****************************************************************************
****************************************************************************/
#ifdef FEATURE_COOKIE_JAR
case hash_jarfile :
- freez((char *)config->jarfile);
+ freez(config->jarfile);
config->jarfile = make_path(config->logdir, arg);
continue;
#endif /* def FEATURE_COOKIE_JAR */
* listen-address [ip][:port]
****************************************************************************/
case hash_listen_address :
- freez((char *)config->haddr);
+ freez(config->haddr);
config->haddr = strdup(arg);
continue;
* logdir directory-name
****************************************************************************/
case hash_logdir :
- freez((char *)config->logdir);
+ freez(config->logdir);
config->logdir = strdup(arg);
- continue;
+ continue;
/****************************************************************************
* logfile log-file-name
* In logdir by default
****************************************************************************/
case hash_logfile :
- freez((char *)config->logfile);
+ freez(config->logfile);
config->logfile = make_path(config->logdir, arg);
continue;
* actions file, the last match wins. However, the internal
* implementations are different: The actions file is stored
* in the same order as the file, and scanned completely.
- * With the ACL, we reverse the order as we load it, then
+ * With the ACL, we reverse the order as we load it, then
* when we scan it we stop as soon as we get a match.
*/
cur_acl->next = config->acl;
* proxy-info-url url
****************************************************************************/
case hash_proxy_info_url :
- freez((char *)config->proxy_info_url);
+ freez(config->proxy_info_url);
config->proxy_info_url = strdup(arg);
continue;
* In confdir by default.
****************************************************************************/
case hash_re_filterfile :
- freez((char *)config->re_filterfile);
+ freez(config->re_filterfile);
config->re_filterfile = make_path(config->confdir, arg);
continue;
****************************************************************************/
#ifdef FEATURE_TRUST
case hash_trustfile :
- freez((char *)config->trustfile);
+ freez(config->trustfile);
config->trustfile = make_path(config->confdir, arg);
continue;
#endif /* def FEATURE_TRUST */
#ifdef FEATURE_TRUST
g_trustfile = config->trustfile;
#endif /* def FEATURE_TRUST */
-
+
#endif /* defined(_WIN32) && !defined (_WIN_CONSOLE) */
/* FIXME: end kludge */
-const char loaders_rcs[] = "$Id: loaders.c,v 1.28 2001/10/07 15:40:39 oes Exp $";
+const char loaders_rcs[] = "$Id: loaders.c,v 1.29 2001/10/23 21:38:53 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loaders.c,v $
*
* Purpose : Functions to load and unload the various
* configuration files. Also contains code to manage
- * the list of active loaders, and to automatically
+ * the list of active loaders, and to automatically
* unload files that are no longer in use.
*
* Copyright : Written by and Copyright (C) 2001 the SourceForge
* IJBSWA team. http://ijbswa.sourceforge.net
*
* Based on the Internet Junkbuster originally written
- * by and Copyright (C) 1997 Anonymous Coders and
+ * by and Copyright (C) 1997 Anonymous Coders and
* Junkbusters Corporation. http://www.junkbusters.com
*
- * This program is free software; you can redistribute it
+ * This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
*
* Revisions :
* $Log: loaders.c,v $
+ * Revision 1.29 2001/10/23 21:38:53 jongfoster
+ * Adding error-checking to create_url_spec()
+ *
* Revision 1.28 2001/10/07 15:40:39 oes
* Replaced 6 boolean members of csp with one bitmap (csp->flags)
*
#include <ctype.h>
#include <assert.h>
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(__OS2__)
#include <unistd.h>
#endif
}
else
- /*
- * this client is not active, release its resources
+ /*
+ * this client is not active, release its resources
* and the ones of all inactive clients that might
* follow it
*/
while (!(ncsp->flags & CSP_FLAG_ACTIVE))
{
csp->next = ncsp->next;
-
+
freez(ncsp->ip_addr_str);
freez(ncsp->my_ip_addr_str);
freez(ncsp->my_hostname);
-
+
#ifdef FEATURE_TRUST
freez(ncsp->referrer);
#endif /* def FEATURE_TRUST */
freez(ncsp->x_forwarded);
freez(ncsp->iob->buf);
-
+
free_http_request(ncsp->http);
-
+
destroy_list(ncsp->headers);
destroy_list(ncsp->cookie_list);
-
+
free_current_action(ncsp->action);
#ifdef FEATURE_STATISTICS
urls_rejected++;
}
#endif /* def FEATURE_STATISTICS */
-
+
freez(ncsp);
-
+
/* are there any more in sequence after it? */
if( !(ncsp = csp->next) )
break;
*
* Description : Helper function to check if a file needs reloading.
* If "current" is still current, return it. Otherwise
- * allocates a new (zeroed) "struct file_list", fills
+ * allocates a new (zeroed) "struct file_list", fills
* in the disk file name and timestamp, and returns it.
*
* Parameters :
* 1 : current = The file_list currently being used - will
- * be checked to see if it is out of date.
+ * be checked to see if it is out of date.
* May be NULL (which is treated as out of
* date).
* 2 : filename = Name of file to check.
continue;
}
- /* Remove leading and trailing whitespace */
+ /* Remove leading and trailing whitespace */
chomp(buf);
if (*buf)
/* We have a meaningful line -> make it a job */
if ((dummy = pcrs_compile_command(buf, &error)) == NULL)
{
- log_error(LOG_LEVEL_RE_FILTER,
+ log_error(LOG_LEVEL_RE_FILTER,
"Adding re_filter job %s failed with error %d.", buf, error);
continue;
}
return( 0 );
load_re_filterfile_error:
- log_error(LOG_LEVEL_FATAL, "can't load re_filterfile '%s': %E",
+ log_error(LOG_LEVEL_FATAL, "can't load re_filterfile '%s': %E",
csp->config->re_filterfile);
return(-1);
* Returns : N/A
*
*********************************************************************/
-void add_loader(int (*loader)(struct client_state *),
+void add_loader(int (*loader)(struct client_state *),
struct configuration_spec * config)
{
int i;
Local Variables:
tab-width: 3
end:
-*/
+*/
\ No newline at end of file
-const char parsers_rcs[] = "$Id: parsers.c,v 1.36 2001/10/13 12:51:51 joergs Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.37 2001/10/23 21:36:02 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/parsers.c,v $
* IJBSWA team. http://ijbswa.sourceforge.net
*
* Based on the Internet Junkbuster originally written
- * by and Copyright (C) 1997 Anonymous Coders and
+ * by and Copyright (C) 1997 Anonymous Coders and
* Junkbusters Corporation. http://www.junkbusters.com
*
- * This program is free software; you can redistribute it
+ * This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
*
* Revisions :
* $Log: parsers.c,v $
+ * Revision 1.37 2001/10/23 21:36:02 jongfoster
+ * Documenting sed()'s error behaviou (doc change only)
+ *
* Revision 1.36 2001/10/13 12:51:51 joergs
* Removed client_host, (was only required for the old 2.0.2-11 http://noijb.
* force-load), instead crumble Host: and add it (again) in client_host_adder
#include <assert.h>
#include <string.h>
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(__OS2__)
#include <unistd.h>
#endif
* as an array index. Therefore we need to make sure that high-bit
* characters generate +ve values, and ideally we also want to make
* the argument match the declared parameter type of "int".
- *
- * Why did they write a character function that can't take a simple
+ *
+ * Why did they write a character function that can't take a simple
* "char" argument? Doh!
*/
#define ijb_isupper(__X) isupper((int)(unsigned char)(__X))
/* { "if-modified-since:", 18, crumble }, */
{ "Keep-Alive:", 11, crumble },
{ "connection:", 11, crumble },
- { "proxy-connection:", 17, crumble },
+ { "proxy-connection:", 17, crumble },
{ NULL, 0, NULL }
};
{ "Content-Type:", 13, server_content_type },
{ "Content-Length:", 15, server_content_length },
{ "Content-MD5:", 12, server_content_md5 },
- { "Content-Encoding:", 17, server_content_encoding },
+ { "Content-Encoding:", 17, server_content_encoding },
{ "Transfer-Encoding:", 18, server_transfer_coding },
{ "Keep-Alive:", 11, crumble },
{ NULL, 0, NULL }
client_x_forwarded_adder,
client_xtra_adder,
client_accept_encoding_adder,
- connection_close_adder,
+ connection_close_adder,
NULL
};
void (* const add_server_headers[])(struct client_state *) = {
- connection_close_adder,
+ connection_close_adder,
NULL
};
if (strncmpic(p->str, v->str, v->len) == 0)
{
hdr = v->parser(v, p->str, csp);
- freez((char *)p->str); /* FIXME: Yuck! patching a list...*/
+ freez(p->str); /* FIXME: Yuck! patching a list...*/
p->str = hdr;
}
}
int n;
memset(http, '\0', sizeof(*http));
- http->cmd = strdup(req);
+ http->cmd = strdup(req);
buf = strdup(req);
n = ssplit(buf, " \r\n", v, SZ(v), 1, 1);
*p = '\0';
http->hostport = strdup(url);
}
- /*
+ /*
* Repair broken HTTP requests that don't contain a path
*/
else
csp->content_type = CT_TABOO;
}
- /*
+ /*
* Raise flag if body chunked
*/
if (strstr(s, "chunked"))
csp->flags |= CSP_FLAG_CHUNKED;
/*
- * If the body was modified, it has been
+ * If the body was modified, it has been
* de-chunked first, so adjust the header:
*/
if (csp->flags & CSP_FLAG_MODIFIED)
#ifdef FEATURE_FORCE_LOAD
/* Since the referrer can include the prefix even
* even if the request itself is non-forced, we must
- * clean it unconditionally
+ * clean it unconditionally
*/
strclean(s, FORCE_PREFIX);
#endif /* def FEATURE_FORCE_LOAD */
if (strstr (s, "image/gif"))
{
/* Client will accept HTML. If this seems counterintuitive,
- * blame Microsoft.
+ * blame Microsoft.
*/
csp->accept_types |= ACCEPT_TYPE_MSIE_HTML;
}
char *server_http(const struct parsers *v, const char *s, struct client_state *csp)
{
char *ret = strdup(s);
-
+
sscanf(ret, "HTTP/%*d.%*d %d", &(csp->http->status));
if (csp->http->status == 206)
{
}
-#ifdef FEATURE_FORCE_LOAD
+#ifdef FEATURE_FORCE_LOAD
/*********************************************************************
*
* Function : strclean
*
- * Description : In-Situ-Eliminate all occurances of substring in
+ * Description : In-Situ-Eliminate all occurances of substring in
* string
*
* Parameters :
p = pos + len;
do
{
- *(p - len) = *p;
+ *(p - len) = *p;
}
while (*p++ != '\0');