From 7c29538f791c5041f23661436380141c95728f79 Mon Sep 17 00:00:00 2001 From: jongfoster Date: Thu, 31 May 2001 21:21:30 +0000 Subject: [PATCH] Permissionsfile / actions file changes: - Changed "permission" to "action" throughout - changes to file format to allow string parameters - Moved helper functions to actions.c --- filters.c | 147 ++++++++++++++++++++++++++---------------------------- filters.h | 34 +++++++++++-- 2 files changed, 102 insertions(+), 79 deletions(-) diff --git a/filters.c b/filters.c index 2de5e29d..346b90e3 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.11 2001/05/29 11:53:23 oes Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.12 2001/05/31 17:35:20 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -6,7 +6,7 @@ const char filters_rcs[] = "$Id: filters.c,v 1.11 2001/05/29 11:53:23 oes Exp $" * Purpose : Declares functions to parse/crunch headers and pages. * Functions declared include: * `acl_addr', `add_stats', `block_acl', `block_imageurl', - * `block_url', `url_permissions', `domaincmp', `dsplit', + * `block_url', `url_actions', `domaincmp', `dsplit', * `filter_popups', `forward_url', 'redirect_url', * `ij_untrusted_url', `intercept_url', `re_process_buffer', * `show_proxy_args', 'ijb_send_banner', and `trust_url' @@ -38,6 +38,11 @@ const char filters_rcs[] = "$Id: filters.c,v 1.11 2001/05/29 11:53:23 oes Exp $" * * Revisions : * $Log: filters.c,v $ + * Revision 1.12 2001/05/31 17:35:20 oes + * + * - Enhanced domain part globbing with infix and prefix asterisk + * matching and optional unanchored operation + * * Revision 1.11 2001/05/29 11:53:23 oes * "See why" link added to "blocked" page * @@ -188,6 +193,7 @@ const char filters_rcs[] = "$Id: filters.c,v 1.11 2001/05/29 11:53:23 oes Exp $" #include "errlog.h" #include "jbsockets.h" #include "miscutil.h" +#include "actions.h" #ifdef _WIN32 #include "win32.h" @@ -417,7 +423,7 @@ char *block_url(struct http_request *http, struct client_state *csp) int n; int factor = 2; - if ((csp->permissions & PERMIT_BLOCK) == 0) + if ((csp->action->flags & ACTION_BLOCK) == 0) { return(NULL); } @@ -478,7 +484,7 @@ int block_imageurl(struct http_request *http, struct client_state *csp) } #endif - return ((csp->permissions & PERMIT_IMAGE) != 0); + return ((csp->action->flags & ACTION_IMAGE) != 0); } #endif /* def IMAGE_BLOCKING */ @@ -906,28 +912,58 @@ char *redirect_url(struct http_request *http, struct client_state *csp) /********************************************************************* * - * Function : url_permissions + * Function : url_actions * - * Description : Gets the permissions for this URL. + * Description : Gets the actions for this URL. * * Parameters : * 1 : http = http_request request for blocked URLs * 2 : csp = Current client state (buffers, headers, etc...) * - * Returns : permissions bitmask specifiying what this URL can do. - * If not on list, will be default_permissions. + * Returns : N/A * *********************************************************************/ -int url_permissions(struct http_request *http, struct client_state *csp) +void url_actions(struct http_request *http, + struct client_state *csp) { struct file_list *fl; - struct permissions_spec *b; + struct url_actions *b; + + init_current_action(csp->action); + + if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL)) + { + return; + } + + apply_url_actions(csp->action, http, b); +} + + +/********************************************************************* + * + * Function : apply_url_actions + * + * Description : Applies a list of URL actions. + * + * Parameters : + * 1 : action = Destination. + * 2 : http = Current URL + * 3 : b = list of URL actions to apply + * + * Returns : N/A + * + *********************************************************************/ +void apply_url_actions(struct current_action_spec *action, + struct http_request *http, + struct url_actions *b) +{ struct url_spec url[1]; - int permissions = csp->config->default_permissions; - if (((fl = csp->permissions_list) == NULL) || ((b = fl->f) == NULL)) + if (b == NULL) { - return(permissions); + /* Should never happen */ + return; } *url = dsplit(http->host); @@ -935,7 +971,7 @@ int url_permissions(struct http_request *http, struct client_state *csp) /* if splitting the domain fails, punt */ if (url->dbuf == NULL) { - return(permissions); + return; } for (b = b->next; NULL != b; b = b->next) @@ -952,8 +988,7 @@ int url_permissions(struct http_request *http, struct client_state *csp) #endif ) { - permissions &= b->mask; - permissions |= b->add; + merge_current_action(action, b->action); } } } @@ -961,8 +996,6 @@ int url_permissions(struct http_request *http, struct client_state *csp) freez(url->dbuf); freez(url->dvec); - return(permissions); - } @@ -1133,6 +1166,8 @@ int domaincmp(struct url_spec *pattern, struct url_spec *fqdn) return ((pn < pattern->dcnt) || ((fn < fqdn->dcnt) && !pattern->unanchored)); + return(0); + } @@ -1174,10 +1209,10 @@ char *show_proxy_args(struct http_request *http, struct client_state *csp) switch (which_file) { case 'p': - if (csp->permissions_list) + if (csp->actions_list) { - filename = csp->permissions_list->filename; - file_description = "Permissions List"; + filename = csp->actions_list->filename; + file_description = "Actions List"; } break; case 'f': @@ -1305,10 +1340,10 @@ char *show_proxy_args(struct http_request *http, struct client_state *csp) "

(Click a filename to view it)

\n" "