APT_DECLARE(apt_bool_t) apt_log_instance_load(const char *config_file, apr_pool_t *pool) { apr_xml_doc *doc; const apr_xml_elem *elem; const apr_xml_elem *root; char *text; if(apt_logger) { return FALSE; } apt_logger = apt_log_instance_alloc(pool); /* Parse XML document */ doc = apt_log_doc_parse(config_file,pool); if(!doc) { return FALSE; } root = doc->root; /* Match document name */ if(!root || strcasecmp(root->name,"aptlogger") != 0) { /* Unknown document */ return FALSE; } /* Navigate through document */ for(elem = root->first_child; elem; elem = elem->next) { if(!elem->first_cdata.first || !elem->first_cdata.first->text) continue; text = apr_pstrdup(pool,elem->first_cdata.first->text); apr_collapse_spaces(text,text); if(strcasecmp(elem->name,"priority") == 0) { apt_logger->priority = apt_log_priority_translate(text); } else if(strcasecmp(elem->name,"output") == 0) { apt_logger->mode = apt_log_output_mode_translate(text); } else if(strcasecmp(elem->name,"headers") == 0) { apt_logger->header = apt_log_header_translate(text); } else if(strcasecmp(elem->name,"masking") == 0) { apt_logger->masking = apt_log_masking_translate(text); } else { /* Unknown element */ } } return TRUE; }
/* Load the setting http-auth-types from the global or server specific section, parse its value and set the types of authentication we should accept from the server. */ static svn_error_t * load_http_auth_types(apr_pool_t *pool, svn_config_t *config, const char *server_group, int *authn_types) { const char *http_auth_types = NULL; *authn_types = SERF_AUTHN_NONE; svn_config_get(config, &http_auth_types, SVN_CONFIG_SECTION_GLOBAL, SVN_CONFIG_OPTION_HTTP_AUTH_TYPES, NULL); if (server_group) { svn_config_get(config, &http_auth_types, server_group, SVN_CONFIG_OPTION_HTTP_AUTH_TYPES, http_auth_types); } if (http_auth_types) { char *token; char *auth_types_list = apr_palloc(pool, strlen(http_auth_types) + 1); apr_collapse_spaces(auth_types_list, http_auth_types); while ((token = svn_cstring_tokenize(";", &auth_types_list)) != NULL) { if (svn_cstring_casecmp("basic", token) == 0) *authn_types |= SERF_AUTHN_BASIC; else if (svn_cstring_casecmp("digest", token) == 0) *authn_types |= SERF_AUTHN_DIGEST; else if (svn_cstring_casecmp("ntlm", token) == 0) *authn_types |= SERF_AUTHN_NTLM; else if (svn_cstring_casecmp("negotiate", token) == 0) *authn_types |= SERF_AUTHN_NEGOTIATE; else return svn_error_createf(SVN_ERR_BAD_CONFIG_VALUE, NULL, _("Invalid config: unknown %s " "'%s'"), SVN_CONFIG_OPTION_HTTP_AUTH_TYPES, token); } } else { /* Nothing specified by the user, so accept all types. */ *authn_types = SERF_AUTHN_ALL; } return SVN_NO_ERROR; }
static const char *log_cookie(request_rec *r, char *a) { const char *cookies_entry; /* * This supports Netscape version 0 cookies while being tolerant to * some properties of RFC2109/2965 version 1 cookies: * - case-insensitive match of cookie names * - white space between the tokens * It does not support the following version 1 features: * - quoted strings as cookie values * - commas to separate cookies */ if ((cookies_entry = apr_table_get(r->headers_in, "Cookie"))) { char *cookie, *last1, *last2; char *cookies = apr_pstrdup(r->pool, cookies_entry); while ((cookie = apr_strtok(cookies, ";", &last1))) { char *name = apr_strtok(cookie, "=", &last2); if (name) { char *value = name + strlen(name) + 1; apr_collapse_spaces(name, name); if (!strcasecmp(name, a)) { char *last; value += strspn(value, " \t"); /* Move past leading WS */ last = value + strlen(value) - 1; while (last >= value && apr_isspace(*last)) { *last = '\0'; --last; } return ap_escape_logitem(r->pool, value); } } cookies = NULL; } } return NULL; }
static apr_status_t akismet_filter(ap_filter_t *f, apr_bucket_brigade *out_brigade, ap_input_mode_t input_mode, apr_read_type_e read_type, apr_off_t nbytes) { akismet_config *conf = NULL; akismet_config *sconf =NULL; akismet_config *dconf =NULL; request_rec *r = f->r; AkismetFilterContext *pctx; apr_status_t ret; apr_table_t *params_table; char* query_string=NULL; int i=0; char *next, *last; /* * decide configuration * use server level config if no directory level config not defined */ sconf = (akismet_config *)ap_get_module_config(r->server->module_config,&akismet_module); dconf = (akismet_config *)ap_get_module_config(r->per_dir_config, &akismet_module); conf = dconf; if ( !dconf || (!dconf->enabled && !dconf->apikey && !dconf->blogurl) ){ conf = sconf; } /* * parse request parameters */ params_table = apr_table_make(r->pool, PARAMS_TABLE_INIT_SIZE); if (!(pctx = f->ctx)) { f->ctx = pctx = apr_palloc(r->pool, sizeof *pctx); pctx->tmp_brigade = apr_brigade_create(r->pool, r->connection->bucket_alloc); } if (APR_BRIGADE_EMPTY(pctx->tmp_brigade)) { ret = ap_get_brigade(f->next, pctx->tmp_brigade, input_mode, read_type, nbytes); if (input_mode == AP_MODE_EATCRLF || ret != APR_SUCCESS) { return ret; } } while( !APR_BRIGADE_EMPTY(pctx->tmp_brigade) ) { apr_bucket *in_bucket = APR_BRIGADE_FIRST(pctx->tmp_brigade); apr_bucket *out_bucket; const char *data; apr_size_t len; char *buf; int n; if(APR_BUCKET_IS_EOS(in_bucket)) { APR_BUCKET_REMOVE(in_bucket); APR_BRIGADE_INSERT_TAIL(out_brigade, in_bucket); break; } ret=apr_bucket_read(in_bucket, &data, &len, read_type); if(ret != APR_SUCCESS){ return ret; } if (query_string == NULL) { query_string = apr_pstrdup(r->pool, data); } else { query_string = apr_pstrcat(r->pool, query_string, data,NULL); } out_bucket = apr_bucket_heap_create(data, len, 0, r->connection->bucket_alloc); APR_BRIGADE_INSERT_TAIL(out_brigade, out_bucket); apr_bucket_delete(in_bucket); } if (!query_string) { return APR_SUCCESS; } /* * split query_string and set params tables */ next = (char*)apr_strtok( query_string, "&", &last); while (next) { apr_collapse_spaces (next, next); char* k, *v; k = (char*)apr_strtok( next, "=", &v); if (k) { if ( ( conf->comment_param_key && strcasecmp( k, conf->comment_param_key)==0) || ( conf->comment_author_param_key && strcasecmp( k, conf->comment_author_param_key)==0) || (conf->comment_author_email_param_key && strcasecmp( k, conf->comment_author_email_param_key)==0) || (conf->comment_author_url_param_key && strcasecmp( k, conf->comment_author_url_param_key)==0) || (conf->comment_permalink_param_key && strcasecmp( k, conf->comment_permalink_param_key)==0) ) { apr_table_set(params_table, k, v); } } next = (char*)apr_strtok(NULL, "&", &last); } /* * comment spam check by akismet api */ return akismet_api_execute(r,conf,params_table); }