You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Randy Terbush <ra...@zyzzyva.com> on 1997/05/27 05:29:01 UTC

Re: [PATCH]: request for harmless mod_include.c patch (fwd)

As someone suggested, USE_PERL_SSI should probably be the macro 
name. Otherwise, +1. This does not break anything.


> Doug wrote:
>  
> > "Roy T. Fielding" <fi...@kiwi.ICS.UCI.EDU> wrote:
> > 
> > > I would expect it to be disabled on IncludesNoExec.  It doesn't seem
> > > to be in the patch.
> > 
> > Agreed, here's another pseudo patch (Rob!)
> > 
> > + if (!(allow_options (r) & OPT_INCLUDES)) return DECLINED;
> 
> 
> Wasn't sure precisely where you wanted to add that..
> 
>    if (!(allow_options (r) & OPT_INCLUDES)) {
>        log_printf(r->server,
>            "httpd: #perl SSI disallowed by IncludesNoExec in %s", r->filename);
>        return DECLINED;
>    }
> 
> I put it at the start of 'handle_perl' and added some logging info.
> 
> 
> The complete patch (including the other earlier changes) is:
> 
> 
> Index: mod_include.c
> ===================================================================
> RCS file: /imdb/cvs/apache/src/mod_include.c,v
> retrieving revision 1.10
> diff -u -r1.10 mod_include.c
> --- mod_include.c	1997/05/11 20:40:26	1.10
> +++ mod_include.c	1997/05/15 21:45:31
> @@ -57,7 +57,24 @@
>   * incorporated into the Apache module framework by rst.
>   * 
>   */
> +/* to enable <!--#perl, 
> + * add -DUSE_PERL -I./ and -I$Config{archlibexp}/CORE to EXTRA_CFLAGS
> + *
> + * sub key may be anything a Perl*Handler can be:
> + * subroutine name, package name (defaults to package::handler),
> + * Class->method call or anoymous sub {}
> + *
> + * Child <!--#perl sub="sub {print $$}" --> accessed
> + * <!--#perl sub="sub {print ++$Access::Cnt }" --> times. <br>
> + *
> + * <!--#perl arg="one" sub="mymod::includer" -->
> + *
> + * -Doug MacEachern
> + */
>  
> +#ifdef USE_PERL
> +#include "modules/perl/mod_perl.h"
> +#else
>  #include "httpd.h"
>  #include "http_config.h"
>  #include "http_request.h"
> @@ -66,6 +83,7 @@
>  #include "http_log.h"
>  #include "http_main.h"
>  #include "util_script.h"
> +#endif
>  
>  #define STARTING_SEQUENCE "<!--#"
>  #define ENDING_SEQUENCE "-->"
> @@ -710,6 +728,32 @@
>          }
>      }
>  }
> +#ifdef USE_PERL
> +int handle_perl (FILE *in, request_rec *r, char *error) {
> +    char tag[MAX_STRING_LEN];
> +    char *tag_val;
> +    SV *sub = Nullsv;
> +    AV *av  = newAV();
> +
> +    if (!(allow_options (r) & OPT_INCLUDES)) {
> +        log_printf(r->server,
> +            "httpd: #perl SSI disallowed by IncludesNoExec in %s", r->filename);
> +	return DECLINED;
> +    }
> +    while(1) {
> +	if(!(tag_val = get_tag (r->pool, in, tag, MAX_STRING_LEN, 1))) 
> +	    break;
> +	if(strnEQ(tag, "sub", 3)) 
> +	    sub = newSVpv(tag_val,0);
> +	else if(strnEQ(tag, "arg", 3)) 
> +	    av_push(av, newSVpv(tag_val,0));	
> +	else if(strnEQ(tag,"done", 4))
> +	    break;
> +    }
> +    perl_call_handler(sub, r, av);
> +    return OK;
> +}
> +#endif
>  
>  /* error and tf must point to a string with room for at 
>   * least MAX_STRING_LEN characters 
> @@ -1674,6 +1718,10 @@
>                  ret=handle_flastmod(f, r, error, timefmt);
>              else if(!strcmp(directive,"printenv"))
>                  ret=handle_printenv(f, r, error);
> +#ifdef USE_PERL
> +            else if(!strcmp(directive,"perl")) 
> +                ret=handle_perl(f, r, error);
> +#endif
>              else {
>                  log_printf(r->server,
>                          "httpd: unknown directive %s in parsed doc %s",
>