예제 #1
0
/* xlate_insert_filter() is a filter hook which decides whether or not
 * to insert a translation filter for the current request.
 */
static void xlate_insert_filter(request_rec *r)
{
    /* Hey... don't be so quick to use reqinfo->dc here; reqinfo may be NULL */
    charset_req_t *reqinfo = ap_get_module_config(r->request_config,
                                                  &charset_lite_module);
    charset_dir_t *dc = ap_get_module_config(r->per_dir_config,
                                             &charset_lite_module);

    if (reqinfo) {
        if (reqinfo->output_ctx && !configured_on_output(r, XLATEOUT_FILTER_NAME)) {
            ap_add_output_filter(XLATEOUT_FILTER_NAME, reqinfo->output_ctx, r,
                                 r->connection);
        }
        else if (dc->debug >= DBGLVL_FLOW) {
            ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                          "xlate output filter not added implicitly because %s",
                          !reqinfo->output_ctx ?
                          "no output configuration available" :
                          "another module added the filter");
        }

        if (reqinfo->input_ctx && !configured_on_input(r, XLATEIN_FILTER_NAME)) {
            ap_add_input_filter(XLATEIN_FILTER_NAME, reqinfo->input_ctx, r,
                                r->connection);
        }
        else if (dc->debug >= DBGLVL_FLOW) {
            ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                          "xlate input filter not added implicitly because %s",
                          !reqinfo->input_ctx ?
                          "no input configuration available" :
                          "another module added the filter");
        }
    }
}
static int upload_progress_handle_request(request_rec *r)
{
/**/up_log(APLOG_MARK, APLOG_DEBUG, 0, r->server, "upload_progress_handle_request()");

    DirConfig* dir = (DirConfig*)ap_get_module_config(r->per_dir_config, &upload_progress_module);
    ServerConfig *config = get_server_config(r->server);

    if (dir && dir->track_enabled > 0) {
        if (r->method_number == M_POST) {

            int param_error;
            const char* id = get_progress_id(r, &param_error);

            if (id) {
                ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                             "Upload Progress: Upload id='%s' in trackable location: %s.", id, r->uri);
                CACHE_LOCK();
                clean_old_connections(r);
                upload_progress_node_t *node = find_node(r, id);
                if (node == NULL) {
                    node = insert_node(r, id);
                    if (node)
                        up_log(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                               "Upload Progress: Added upload with id='%s' to list.", id);
                } else if (node->done) {
                    fill_new_upload_node_data(node, r);
                    up_log(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                                 "Upload Progress: Reused existing node with id='%s'.", id);
                } else {
                    node = NULL;
                    ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
                                 "Upload Progress: Upload with id='%s' already exists, ignoring.", id);
                }

                if (node) {
                    upload_progress_context_t *ctx = (upload_progress_context_t*)apr_pcalloc(r->pool, sizeof(upload_progress_context_t));
                    ctx->node = node;
                    ctx->r = r;
                    apr_pool_cleanup_register(r->pool, ctx, upload_progress_cleanup, apr_pool_cleanup_null);
                    ap_add_input_filter("UPLOAD_PROGRESS", NULL, r, r->connection);
                }
                CACHE_UNLOCK();

            } else if (param_error < 0) {
                ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                             "Upload Progress: Upload with invalid ID in trackable location: %s.", r->uri);
                /*
                return HTTP_BAD_REQUEST;
                return HTTP_NOT_FOUND;
                */

            } else {
                ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                             "Upload Progress: Upload without ID in trackable location: %s.", r->uri);
            }
        }
    }

    return DECLINED;
}
예제 #3
0
파일: mirror.c 프로젝트: DJEX93/dsploit
/* Tweak the request record R, and add the necessary filters, so that
   the request is ready to be proxied away.  MASTER_URI is the URI
   specified in the SVNMasterURI Apache configuration value.
   URI_SEGMENT is the URI bits relative to the repository root (but if
   non-empty, *does* have a leading slash delimiter).
   MASTER_URI and URI_SEGMENT are not URI-encoded. */
static int proxy_request_fixup(request_rec *r,
                               const char *master_uri,
                               const char *uri_segment)
{
    if (uri_segment[0] != '\0' && uri_segment[0] != '/')
      {
        ap_log_rerror(APLOG_MARK, APLOG_ERR, SVN_ERR_BAD_CONFIG_VALUE, r,
                     "Invalid URI segment '%s' in slave fixup",
                      uri_segment);
        return HTTP_INTERNAL_SERVER_ERROR;
      }

    r->proxyreq = PROXYREQ_REVERSE;
    r->uri = r->unparsed_uri;
    r->filename = (char *) svn_path_uri_encode(apr_pstrcat(r->pool, "proxy:",
                                                           master_uri,
                                                           uri_segment,
                                                           (char *)NULL),
                                               r->pool);
    r->handler = "proxy-server";
    ap_add_output_filter("LocationRewrite", NULL, r, r->connection);
    ap_add_output_filter("ReposRewrite", NULL, r, r->connection);
    ap_add_input_filter("IncomingRewrite", NULL, r, r->connection);
    return OK;
}
static int upload_progress_handle_request(request_rec *r)
{
  DirConfig* dir = (DirConfig*)ap_get_module_config(r->per_dir_config, &upload_progress_module);
  ServerConfig *config = get_server_config(r);
  
  if(dir->track_enabled) {
    if(r->method_number == M_POST) {
      ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                         "Upload Progress: Upload in trackable location: %s.", r->uri);
      const char* id = get_progress_id(r);
      if(id != NULL) {
        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                         "Upload Progress: Progress id found: %s.", id);
        CACHE_LOCK();
        upload_progress_node_t *node = find_node(r, id);
	CACHE_UNLOCK();
        if(node == NULL) {
          add_upload_to_track(r, id);
          ap_add_input_filter("UPLOAD_PROGRESS", NULL, r, r->connection);
	} else {
          ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                         "Upload Progress: Node with id '%s' already exists.", id);
	}
        return DECLINED;
      }
    }
  }
  
  return DECLINED;
}
예제 #5
0
/* Tweak the request record R, and add the necessary filters, so that
   the request is ready to be proxied away.  MASTER_URI is the URI
   specified in the SVNMasterURI Apache configuration value.
   URI_SEGMENT is the URI bits relative to the repository root (but if
   non-empty, *does* have a leading slash delimiter).
   MASTER_URI and URI_SEGMENT are not URI-encoded. */
static int proxy_request_fixup(request_rec *r,
                               const char *master_uri,
                               const char *uri_segment)
{
    if (uri_segment[0] != '\0' && uri_segment[0] != '/')
      {
        ap_log_rerror(APLOG_MARK, APLOG_ERR, SVN_ERR_BAD_CONFIG_VALUE, r,
                     "Invalid URI segment '%s' in slave fixup",
                      uri_segment);
        return HTTP_INTERNAL_SERVER_ERROR;
      }

    r->proxyreq = PROXYREQ_REVERSE;
    r->uri = r->unparsed_uri;
    r->filename = (char *) svn_path_uri_encode(apr_pstrcat(r->pool, "proxy:",
                                                           master_uri,
                                                           uri_segment,
                                                           SVN_VA_NULL),
                                               r->pool);
    r->handler = "proxy-server";

    /* ### FIXME: Seems we could avoid adding some or all of these
           filters altogether when the root_dir (that is, the slave's
           location, relative to the server root) and path portion of
           the master_uri (the master's location, relative to the
           server root) are identical, rather than adding them here
           and then trying to remove them later.  (See the filter
           removal logic in dav_svn__location_in_filter() and
           dav_svn__location_body_filter().  -- cmpilato */

    ap_add_output_filter("LocationRewrite", NULL, r, r->connection);
    ap_add_output_filter("ReposRewrite", NULL, r, r->connection);
    ap_add_input_filter("IncomingRewrite", NULL, r, r->connection);
    return OK;
}
예제 #6
0
/**
 * Pre Connection
 */
static int pre_connection(conn_rec *c, void *csd)
{
    my_config *conf = ap_get_module_config (c->base_server->module_config, &myfixip_module);

#ifdef DEBUG
    ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, MODULE_NAME "::pre_connection IP Connection remote: %s:%d localport=%d (1)", _CLIENT_IP, _CLIENT_ADDR->port, c->local_addr->port);
#endif

    if (!check_inbound(c)) { // Not Inbound (mod_proxy)
        return DECLINED;
    }

#ifdef DEBUG
    ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, MODULE_NAME "::pre_connection IP Connection from: %s:%d to port=%d (1)", _CLIENT_IP, _CLIENT_ADDR->port, c->local_addr->port);
#endif

    if (!check_trusted(c, conf)) { // Not Trusted
        return DECLINED;
    }

    my_ctx *cctx = apr_palloc(c->pool, sizeof(my_ctx));
    cctx->phase = PHASE_WANT_HEAD;
    cctx->mode = AP_MODE_READBYTES;
    cctx->need = PROXY_HEAD_LENGTH;
    cctx->recv = 0;
    cctx->offset = 0;
    memset(cctx->buf, 0, sizeof(cctx->buf));
    cctx->magic = (PAD_MAGIC ^ c->id ^ conf->time) & 0x7FFFFFFF;
    cctx->pad = cctx->magic;

    ap_add_input_filter(myfixip_filter_name, cctx, NULL, c);

    return DECLINED;
}
예제 #7
0
파일: mod_sslhaf.c 프로젝트: Ath103/sslhaf
/**
 * Attach our filter to every incoming connection.
 */
static int mod_sslhaf_pre_conn(conn_rec *c, void *csd) {
    sslhaf_cfg_t *cfg = NULL;

    // TODO Can we determine if SSL is enabled on this connection
    //      and don't bother if it isn't? It is actually possible that
    //      someone speaks SSL on a non-SSL connection, but we won't
    //      be able to detect that. It wouldn't matter, though, because
    //      Apache will not process such a request.

    cfg = sslhaf_cfg_create(
        c,
        &mod_sslhaf_alloc,
        &mod_sslhaf_free,
        &mod_sslhaf_snprintf,
        &mod_sslhaf_log);
    if (cfg == NULL)
        return OK;

    sslhaf_cfg_set_create_strings(cfg, true);

    ap_set_module_config(c->conn_config, &sslhaf_module, cfg);

    ap_add_input_filter(mod_sslhaf_in_filter_name, NULL, NULL, c);
    ap_add_output_filter(mod_sslhaf_out_filter_name, NULL, NULL, c);

    #ifdef ENABLE_DEBUG
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, c->base_server,
        "mod_sslhaf: Connection from %s", SSLHAF_AP_CONN_REMOTE_IP(c));
    #endif

    return OK;
}
예제 #8
0
파일: h2_h2.c 프로젝트: practicalswift/osx
static int h2_h2_post_read_req(request_rec *r)
{
    /* slave connection? */
    if (r->connection->master) {
        h2_ctx *ctx = h2_ctx_rget(r);
        struct h2_task *task = h2_ctx_get_task(ctx);
        /* This hook will get called twice on internal redirects. Take care
         * that we manipulate filters only once. */
        if (task && !task->filters_set) {
            ap_filter_t *f;
            ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r, 
                          "h2_task(%s): adding request filters", task->id);

            /* setup the correct filters to process the request for h2 */
            ap_add_input_filter("H2_REQUEST", task, r, r->connection);
            
            /* replace the core http filter that formats response headers
             * in HTTP/1 with our own that collects status and headers */
            ap_remove_output_filter_byhandle(r->output_filters, "HTTP_HEADER");
            ap_add_output_filter("H2_RESPONSE", task, r, r->connection);
            
            for (f = r->input_filters; f; f = f->next) {
                if (!strcmp("H2_SLAVE_IN", f->frec->name)) {
                    f->r = r;
                    break;
                }
            }
            ap_add_output_filter("H2_TRAILERS_OUT", task, r, r->connection);
            task->filters_set = 1;
        }
    }
    return DECLINED;
}
예제 #9
0
static void CaseFilterInInsertFilter(request_rec *r)
{
    CaseFilterInConfig *pConfig=ap_get_module_config(r->server->module_config,
                                                     &case_filter_in_module);
    if(!pConfig->bEnabled)
        return;

    ap_add_input_filter(s_szCaseFilterName,NULL,r,r->connection);
}
static int logio_pre_conn(conn_rec *c, void *csd) {
    logio_config_t *cf = apr_pcalloc(c->pool, sizeof(*cf));

    ap_set_module_config(c->conn_config, &logio_module, cf);

    ap_add_input_filter(logio_filter_name, NULL, NULL, c);

    return OK;
}
예제 #11
0
static int dumpio_pre_conn(conn_rec *c, void *csd)
{
    dumpio_conf_t *ptr =
    (dumpio_conf_t *) ap_get_module_config(c->base_server->module_config,
                                           &dumpio_module);
    
    if (ptr->enable_input)
        ap_add_input_filter("DUMPIO_IN", NULL, NULL, c);
    if (ptr->enable_output)
        ap_add_output_filter("DUMPIO_OUT", NULL, NULL, c);
    return OK;
}
예제 #12
0
static void
 akismet_insert_filter(request_rec *r)
{
    akismet_config *conf = NULL;
    akismet_config *sconf =NULL;
    akismet_config *dconf =NULL;

    /*
    * 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;
    }

    if (!conf || !conf->enabled || !api_cache_shm_file || !global_lock_file) {
        return;
    }
#ifdef AKISMET_DEBUG
dump_akismet_config(r, conf);
#endif
    /*
    *  required configuration check
    */
    if (!conf->apikey) {
        ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
                MODTAG "AkismetApiKey is not specified!");
        return;
    }
    if (!conf->blogurl) {
        ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
                MODTAG "AkismetBlogURL is not specified!");
        return;
    }
    if (!conf->comment_param_key) {
        ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
                MODTAG "AkismetCommentParamKey is not specified!");
        return;
    }
    ap_add_input_filter(akismet_filter_name,NULL,r,r->connection);
}
예제 #13
0
static void
merge_xml_filter_insert(request_rec *r)
{
  /* We only care about MERGE and DELETE requests. */
  if ((r->method_number == M_MERGE)
      || (r->method_number == M_DELETE))
    {
      dir_conf_t *conf;
      conf = ap_get_module_config(r->per_dir_config, &dav_svn_module);

      /* We only care if we are configured. */
      if (conf->fs_path || conf->fs_parent_path)
        {
          ap_add_input_filter("SVN-MERGE", NULL, r, r->connection);
        }
    }
}
예제 #14
0
파일: h2_task.c 프로젝트: ikyaqoob/mod_h2
int h2_task_pre_conn(h2_task_env *env, conn_rec *c)
{
    AP_DEBUG_ASSERT(env);
    /* Add our own, network level in- and output filters.
     */
    ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c,
                  "h2_stream(%s): task_pre_conn, installing filters",
                  env->id);
    
    ap_add_input_filter("H2_TO_H1", env, NULL, c);
    ap_add_output_filter("H1_TO_H2", env, NULL, c);
    
    /* prevent processing by anyone else, including httpd core */
    ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c,
                  "h2_stream(%s): task_pre_conn, taking over", env->id);
    return DONE;
}
예제 #15
0
/* Tweak the request record R, and add the necessary filters, so that
   the request is ready to be proxied away.  MASTER_URI is the URI
   specified in the SVNMasterURI Apache configuration value.
   URI_SEGMENT is the URI bits relative to the repository root (but if
   non-empty, *does* have a leading slash delimiter).
   MASTER_URI and URI_SEGMENT are not URI-encoded. */
static void proxy_request_fixup(request_rec *r,
                                const char *master_uri,
                                const char *uri_segment)
{
    assert((uri_segment[0] == '\0')
           || (uri_segment[0] == '/'));

    r->proxyreq = PROXYREQ_REVERSE;
    r->uri = r->unparsed_uri;
    r->filename = (char *) svn_path_uri_encode(apr_pstrcat(r->pool, "proxy:",
                                                           master_uri,
                                                           uri_segment,
                                                           (char *)NULL),
                                               r->pool);
    r->handler = "proxy-server";
    ap_add_output_filter("LocationRewrite", NULL, r, r->connection);
    ap_add_output_filter("ReposRewrite", NULL, r, r->connection);
    ap_add_input_filter("IncomingRewrite", NULL, r, r->connection);
}
예제 #16
0
static int h2_task_pre_conn(conn_rec* c, void *arg)
{
    h2_ctx *ctx;
    
    if (!c->master) {
        return OK;
    }
    
    ctx = h2_ctx_get(c, 0);
    (void)arg;
    if (h2_ctx_is_task(ctx)) {
        ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, c,
                      "h2_h2, pre_connection, found stream task");
        ap_add_input_filter("H2_SLAVE_IN", NULL, NULL, c);
        ap_add_output_filter("H2_PARSE_H1", NULL, NULL, c);
        ap_add_output_filter("H2_SLAVE_OUT", NULL, NULL, c);
    }
    return OK;
}
예제 #17
0
파일: h2_task.c 프로젝트: AzerTyQsdF/osx
static int h2_task_pre_conn(conn_rec* c, void *arg)
{
    
    h2_ctx *ctx = h2_ctx_get(c);
    
    (void)arg;
    if (h2_ctx_is_task(ctx)) {
        h2_task *task = h2_ctx_get_task(ctx);
        
        ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, c,
                      "h2_h2, pre_connection, found stream task");
        
        /* Add our own, network level in- and output filters.
         */
        ap_add_input_filter("H2_TO_H1", task, NULL, c);
        ap_add_output_filter("H1_TO_H2", task, NULL, c);
    }
    return OK;
}
예제 #18
0
/**
 * A hook that is called before a connection is handled. This function will
 * get the module configuration and add the flash socket policy filters if
 * a cross-domain policy has been specified in the configuration.
 *
 * @param c the connection.
 * @param csd the connection socket descriptor.
 *
 * @return OK on success.
 */
static int fsp_pre_connection(conn_rec* c, void* csd)
{
   // only install filters if a policy was specified in the module config
   fsp_config* cfg = ap_get_module_config(
      c->base_server->module_config, &fsp_module);
   if(cfg->policy != NULL)
   {
      // allocate filter state
      filter_state* state = apr_palloc(c->pool, sizeof(filter_state));
      if(state != NULL)
      {
         // initialize state
         state->cfg = cfg;
         state->checked = state->found = 0;

         // add filters
         ap_add_input_filter("fsp_request", state, NULL, c);
         ap_add_output_filter("fsp_response", state, NULL, c);
      }
   }

   return OK;
}
예제 #19
0
/* xlate_insert_filter() is a filter hook which decides whether or not
 * to insert a translation filter for the current request.
 */
static void xlate_insert_filter(request_rec *r)
{
    /* Hey... don't be so quick to use reqinfo->dc here; reqinfo may be NULL */
    charset_req_t *reqinfo = ap_get_module_config(r->request_config,
                                                  &charset_lite_module);
    charset_dir_t *dc = ap_get_module_config(r->per_dir_config,
                                             &charset_lite_module);

    if (dc && (dc->implicit_add == IA_NOIMPADD)) {
        ap_log_rerror(APLOG_MARK, APLOG_TRACE6, 0, r,
                      "xlate output filter not added implicitly because "
                      "CharsetOptions included 'NoImplicitAdd'");
        return;
    }

    if (reqinfo) {
        if (reqinfo->output_ctx && !configured_on_output(r, XLATEOUT_FILTER_NAME)) {
            ap_add_output_filter(XLATEOUT_FILTER_NAME, reqinfo->output_ctx, r,
                                 r->connection);
        }
        ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r,
                      "xlate output filter not added implicitly because %s",
                      !reqinfo->output_ctx ?
                      "no output configuration available" :
                      "another module added the filter");

        if (reqinfo->input_ctx && !configured_on_input(r, XLATEIN_FILTER_NAME)) {
            ap_add_input_filter(XLATEIN_FILTER_NAME, reqinfo->input_ctx, r,
                                r->connection);
        }
        ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r,
                      "xlate input filter not added implicitly because %s",
                      !reqinfo->input_ctx ?
                      "no input configuration available" :
                      "another module added the filter");
    }
}
예제 #20
0
파일: h2_task.c 프로젝트: nickrace/mod_h2
static int h2_task_pre_conn(conn_rec* c, void *arg)
{
    (void)arg;
    
    h2_ctx *ctx = h2_ctx_get(c);
    if (h2_ctx_is_task(ctx)) {
        h2_task_env *env = h2_ctx_get_task(ctx);
        
        /* This connection is a pseudo-connection used for a h2_task.
         * Since we read/write directly from it ourselves, we need
         * to disable a possible ssl connection filter.
         */
        h2_tls_disable(c);
        
        ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, c,
                      "h2_h2, pre_connection, found stream task");
        
        /* Add our own, network level in- and output filters.
         */
        ap_add_input_filter("H2_TO_H1", env, NULL, c);
        ap_add_output_filter("H1_TO_H2", env, NULL, c);
    }
    return OK;
}
예제 #21
0
/**
 * @internal
 *
 * Setup the connection structures, filters and a disconnect handler.
 */
static int ironbee_pre_connection(conn_rec *c, void *csd)
{
    ib_conn_t *iconn = NULL;
    ib_status_t rc;
    ironbee_conn_context *ctx_in;
    ironbee_conn_context *ctx_out;
    ironbee_config_t *modcfg =
        (ironbee_config_t *)ap_get_module_config(c->base_server->module_config,
                                               &ironbee_module);

    if (!modcfg->enabled) {
        return DECLINED;
    }

    /* Ignore backend connections. The backend connection does not have
     * a handle to the scoreboard. */
    if (c->sbh == NULL) {
        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, c->base_server,
                     IB_PRODUCT_NAME ": Skipping proxy connect");
        return DECLINED;
    }

    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, c->base_server,
                 IB_PRODUCT_NAME ": ironbee_pre_connection remote=%pI local=%pI",
                 (void *)c->remote_addr, (void *)c->local_addr);

    /* Create the connection structure. */
    /// @todo Perhaps the engine should do this instead via an event???
    ib_log_debug(ironbee, 9, "Creating connection structure");
    rc = ib_conn_create(ironbee, &iconn, c);
    if (rc != IB_OK) {
        return DECLINED;
    }

    /* Tell the engine a connection has started. */
    ib_state_notify_conn_opened(ironbee, iconn);

    /* Create the incoming context. */
    ctx_in = apr_pcalloc(c->pool, sizeof(*ctx_in));
    ctx_in->iconn = iconn;
    ctx_in->direction = IRONBEE_REQUEST;
    apr_table_setn(c->notes, "IRONBEE_CTX_IN", (void *)ctx_in);

    /* Create the outgoing context. */
    ctx_out = apr_pcalloc(c->pool, sizeof(*ctx_out));
    ctx_out->iconn = iconn;
    ctx_out->direction = IRONBEE_RESPONSE;
    apr_table_setn(c->notes, "IRONBEE_CTX_OUT", (void *)ctx_out);

    /* Register callback on disconnect. */
    /// @todo use apr_pool_pre_cleanup_register() when APR >= 1.3
    apr_pool_cleanup_register(c->pool, c, ironbee_disconnection, NULL);

    /* Add the connection level filters which generate I/O events. */
    ap_add_input_filter("IRONBEE_IN", ctx_in, NULL, c);
#ifdef IB_DEBUG
    ap_add_input_filter("IRONBEE_DBG_IN", ctx_in, NULL, c);
#endif
    ap_add_output_filter("IRONBEE_OUT", ctx_out, NULL, c);

    return OK;
}
예제 #22
0
파일: agent.c 프로젝트: JonathanFu/OpenAM-1
static void amagent_auth_post_insert_filter(request_rec *r) {
    ap_add_input_filter(amagent_post_filter_name, NULL, r, r->connection);
}
예제 #23
0
// -----------------------------------------------------------------------------
int
trell_job_rpc_handle( trell_sconf_t* sconf,
                      request_rec*r,
                      xmlSchemaPtr schema,
                      const char* job,
                      trell_dispatch_info_t*  dispatch_info )
{
    
    // set up request config
    req_cfg_t* req_cfg = apr_palloc( r->pool, sizeof(*req_cfg) );
    req_cfg->m_schema = schema;
    ap_set_module_config( r->request_config, tinia_get_module(), req_cfg );
    // add validation filter
    ap_add_input_filter( "tinia_validate_xml", NULL, r, r->connection );
    
    if( r->method_number != M_POST ) {  // should be checked earlier
        ap_log_rerror( APLOG_MARK, APLOG_ERR, 0, r, "mod_trell: method != POST" );
        return HTTP_METHOD_NOT_ALLOWED;
    }
    // check if content type is correct
    const char* content_type = apr_table_get( r->headers_in, "Content-Type" );
    if( content_type == NULL ) {
        ap_log_rerror(  APLOG_MARK, APLOG_ERR, 0, r, "mod_trell: No content type" );
        return HTTP_BAD_REQUEST;
    }

    // In case we get Content-Type: text/xml; encoding=foo.
    char* semicolon = strchr( content_type, ';' );
    if( semicolon != NULL ) {
        // Chop line at semicolon.
        *semicolon = '\0';
    }
    if( ! ( ( strcasecmp( "application/xml", content_type) == 0 ) ||
            ( strcasecmp( "text/xml", content_type ) == 0 ) ) )
    {
        ap_log_rerror( APLOG_MARK, APLOG_ERR, 0, r,
                       "mod_trell: Unsupported content-type '%s'", content_type );
        return HTTP_BAD_REQUEST;
    }

    tinia_msg_xml_t query;
    query.msg.type = TRELL_MESSAGE_XML;

    trell_pass_query_msg_post_data_t pass_query_data;
    pass_query_data.sconf          = sconf;
    pass_query_data.r              = r;
    pass_query_data.dispatch_info  = dispatch_info;
    pass_query_data.message        = &query;
    pass_query_data.message_offset = 0;
    pass_query_data.message_size   = sizeof(query);
    pass_query_data.pass_post      = 1;

    tinia_pass_reply_data_t pass_reply_data;
    pass_reply_data.sconf         = sconf;
    pass_reply_data.r             = r;
    pass_reply_data.dispatch_info = dispatch_info;
    pass_reply_data.longpolling   = 0;
    pass_reply_data.brigade       = NULL;
    

    int rv = tinia_ipc_msg_client_sendrecv_by_name( job,
                                                    trell_messenger_log_wrapper, r,
                                                    trell_pass_query_msg_post, &pass_query_data,
                                                    trell_pass_reply, &pass_reply_data,
                                                    0 );
    if( rv == 0 ) {
        return OK;
    }
    else if( rv == -1 ) {
        return HTTP_REQUEST_TIME_OUT;
    }
    else {
        ap_log_rerror( APLOG_MARK, APLOG_NOTICE, 0, r, "%s: failed.", r->path_info );
        return HTTP_INTERNAL_SERVER_ERROR;
    }
}