⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_dontdothat.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
      case STATE_IN_RECURSIVE:        if (! ctx->buffer)          ctx->buffer = svn_stringbuf_ncreate(data, len, ctx->r->pool);        else          svn_stringbuf_appendbytes(ctx->buffer, data, len);        break;      default:        break;    }}static voidstart_element(void *baton, const char *name, const char **attrs){  dontdothat_filter_ctx *ctx = baton;  const char *sep;  if (ctx->no_soup_for_you || ctx->let_it_go)    return;  /* XXX Hack.  We should be doing real namespace support, but for now we   *     just skip ahead of any namespace prefix.  If someone's sending us   *     an update-report element outside of the SVN namespace they'll get   *     what they deserve... */  sep = ap_strchr_c(name, ':');  if (sep)    name = sep + 1;  switch (ctx->state)    {      case STATE_BEGINNING:        if (strcmp(name, "update-report") == 0)          ctx->state = STATE_IN_UPDATE;        else if (strcmp(name, "replay-report") == 0)          {            /* XXX it would be useful if there was a way to override this             *     on a per-user basis... */            if (! is_this_legal(ctx, ctx->r->unparsed_uri))              ctx->no_soup_for_you = TRUE;            else              ctx->let_it_go = TRUE;          }        else          ctx->let_it_go = TRUE;        break;      case STATE_IN_UPDATE:        if (strcmp(name, "src-path") == 0)          {            ctx->state = STATE_IN_SRC_PATH;            if (ctx->buffer)              ctx->buffer->len = 0;          }        else if (strcmp(name, "dst-path") == 0)          {            ctx->state = STATE_IN_DST_PATH;            if (ctx->buffer)              ctx->buffer->len = 0;          }        else if (strcmp(name, "recursive") == 0)          {            ctx->state = STATE_IN_RECURSIVE;            if (ctx->buffer)              ctx->buffer->len = 0;          }        else          ; /* XXX Figure out what else we need to deal with...  Switch             *     has that link-path thing we probably need to look out             *     for... */        break;      default:        break;    }}static voidend_element(void *baton, const char *name){  dontdothat_filter_ctx *ctx = baton;  const char *sep;  if (ctx->no_soup_for_you || ctx->let_it_go)    return;  /* XXX Hack.  We should be doing real namespace support, but for now we   *     just skip ahead of any namespace prefix.  If someone's sending us   *     an update-report element outside of the SVN namespace they'll get   *     what they deserve... */  sep = ap_strchr_c(name, ':');  if (sep)    name = sep + 1;  switch (ctx->state)    {      case STATE_IN_SRC_PATH:        ctx->state = STATE_IN_UPDATE;        svn_stringbuf_strip_whitespace(ctx->buffer);        if (! ctx->path_failed && ! is_this_legal(ctx, ctx->buffer->data))          ctx->path_failed = TRUE;        break;      case STATE_IN_DST_PATH:        ctx->state = STATE_IN_UPDATE;        svn_stringbuf_strip_whitespace(ctx->buffer);        if (! ctx->path_failed && ! is_this_legal(ctx, ctx->buffer->data))          ctx->path_failed = TRUE;        break;      case STATE_IN_RECURSIVE:        ctx->state = STATE_IN_UPDATE;        svn_stringbuf_strip_whitespace(ctx->buffer);        /* If this isn't recursive we let it go. */        if (strcmp(ctx->buffer->data, "no") == 0)          {            ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, ctx->r,                          "mod_dontdothat: letting nonrecursive request go");            ctx->let_it_go = TRUE;          }        break;      case STATE_IN_UPDATE:        if (strcmp(name, "update-report") == 0)          {            /* If we made it here without figuring out that this is             * nonrecursive, then the path check is our final word             * on the subject. */            if (ctx->path_failed)              ctx->no_soup_for_you = TRUE;            else              ctx->let_it_go = TRUE;          }        else          ; /* XXX Is there other stuff we care about? */        break;      default:        abort();    }}static svn_boolean_tis_valid_wildcard(const char *wc){  while (*wc)    {      if (*wc == '*')        {          if (wc[1] && wc[1] != '/')            return FALSE;        }      ++wc;    }  return TRUE;}static svn_boolean_tconfig_enumerator(const char *wildcard,                  const char *action,                  void *baton,                  apr_pool_t *pool){  dontdothat_filter_ctx *ctx = baton;  if (strcmp(action, "deny") == 0)    {      if (is_valid_wildcard(wildcard))        APR_ARRAY_PUSH(ctx->no_recursive_ops, const char *) = wildcard;      else        ctx->err = svn_error_createf(APR_EINVAL,                                     NULL,                                     "'%s' is an invalid wildcard",                                     wildcard);    }  else if (strcmp(action, "allow") == 0)    {      if (is_valid_wildcard(wildcard))        APR_ARRAY_PUSH(ctx->allow_recursive_ops, const char *) = wildcard;      else        ctx->err = svn_error_createf(APR_EINVAL,                                     NULL,                                     "'%s' is an invalid wildcard",                                     wildcard);    }  else    {      ctx->err = svn_error_createf(APR_EINVAL,                                   NULL,                                   "'%s' is not a valid action",                                   action);    }  if (ctx->err)    return FALSE;  else    return TRUE;}static apr_status_tclean_up_parser(void *baton){  XML_Parser xmlp = baton;  XML_ParserFree(xmlp);  return APR_SUCCESS;}static voiddontdothat_insert_filters(request_rec *r){  dontdothat_config_rec *cfg = ap_get_module_config(r->per_dir_config,                                                    &dontdothat_module);  if (! cfg->config_file)    return;  if (strcmp("REPORT", r->method) == 0)    {      dontdothat_filter_ctx *ctx = apr_pcalloc(r->pool, sizeof(*ctx));      svn_config_t *config;      svn_error_t *err;      ctx->r = r;      ctx->cfg = cfg;      ctx->allow_recursive_ops = apr_array_make(r->pool, 5, sizeof(char *));      ctx->no_recursive_ops = apr_array_make(r->pool, 5, sizeof(char *));      /* XXX is there a way to error out from this point?  Would be nice... */      err = svn_config_read(&config, cfg->config_file, TRUE, r->pool);      if (err)        {          char buff[256];          ap_log_rerror(APLOG_MARK, APLOG_ERR,                        ((err->apr_err >= APR_OS_START_USERERR &&                          err->apr_err < APR_OS_START_CANONERR) ?                         0 : err->apr_err),                        r, "Failed to load DontDoThatConfigFile: %s",                        svn_err_best_message(err, buff, sizeof(buff)));          svn_error_clear(err);          return;        }      svn_config_enumerate2(config,                            "recursive-actions",                            config_enumerator,                            ctx,                            r->pool);      if (ctx->err)        {          char buff[256];          ap_log_rerror(APLOG_MARK, APLOG_ERR,                        ((ctx->err->apr_err >= APR_OS_START_USERERR &&                          ctx->err->apr_err < APR_OS_START_CANONERR) ?                         0 : ctx->err->apr_err),                        r, "Failed to parse DontDoThatConfigFile: %s",                        svn_err_best_message(ctx->err, buff, sizeof(buff)));          svn_error_clear(ctx->err);          return;        }      ctx->state = STATE_BEGINNING;      ctx->xmlp = XML_ParserCreate(NULL);      apr_pool_cleanup_register(r->pool, ctx->xmlp, clean_up_parser, NULL);      XML_SetUserData(ctx->xmlp, ctx);      XML_SetElementHandler(ctx->xmlp, start_element, end_element);      XML_SetCharacterDataHandler(ctx->xmlp, cdata);      ap_add_input_filter("DONTDOTHAT_FILTER", ctx, r, r->connection);    }}static voiddontdothat_register_hooks(apr_pool_t *pool){  ap_hook_insert_filter(dontdothat_insert_filters, NULL, NULL, APR_HOOK_FIRST);  ap_register_input_filter("DONTDOTHAT_FILTER",                           dontdothat_filter,                           NULL,                           AP_FTYPE_RESOURCE);}module AP_MODULE_DECLARE_DATA dontdothat_module ={  STANDARD20_MODULE_STUFF,  create_dontdothat_dir_config,  NULL,  NULL,  NULL,  dontdothat_cmds,  dontdothat_register_hooks};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -