You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Doug MacEachern <do...@telebusiness.co.nz> on 1998/01/07 09:08:29 UTC

[PATCH] add -C and -c switches (take 2)

okay, here it is again now using array_header's.  This patch also
includes a special check for PerlModule #ifdef MOD_PERL until I figure
out the real problem.  The problem I mentioned yesterday only happens
when no .conf files are read and PerlModule bootstraps the
"<Perl></Perl>" section itself so all config can be read from the
%Apache::ReadConfig:: symbol table.   The #ifdef MOD_PERL bit cures this
problem.

-Doug

p.s. sorry I've not been updating STATUS for this stuff, but I still
can't telnet/ssh from my linux box to the outside world yet.  I'd have
to re-boot into win95 and telnet to taz :-(


Re: [PATCH] add -C and -c switches (take 2)

Posted by Doug MacEachern <do...@telebusiness.co.nz>.
Martin Kraemer wrote:

> On Wed, Jan 07, 1998 at 09:08:29PM +1300, Doug MacEachern wrote:
> > +    fprintf(stderr, "Usage: %s [-d directory] [-f file] [-C|-c command] [-v] [-h] [-l]\n", bin);
> > ...
> > +    fprintf(stderr, "-C command : process command before reading config files\n");
> > +    fprintf(stderr, "-c command : process command after reading config files\n");
>
> Shouldn't "command" be called "directive"?

Well, the string passed to handle_command is a directive and it's args, which together make a command,
right?  Plus, -c -C is the first letter of command :-)

> > +void process_command_config(server_rec *s, array_header *arr, pool *p, pool *ptemp)
> > +{
> > ...
> > +#ifdef MOD_PERL
> > +     if(!(strncmp(line, "PerlModule ", 11))) {
> > ...
> > +         errmsg = perl_cmd_module(&parms, s->lookup_defaults, line);
> > +
> > +         if (!errmsg)
> > +             continue;
>
> Does perl_cmd_module() print the errmsg string already? And are
> the returned errors assumed to be non-fatal?

actually, perl will die a fatal death, exit, etc. if there's an error message.  I should have just
made that:       (void)perl_cmd_module(&parms, s->lookup_defaults, line);

as it was in the -M patch.

> > +     }
> > +#endif
>
> >  void process_resource_config(server_rec *s, char *fname, pool *p, pool *ptemp)
> >  {
> >      const char *errmsg;
> > @@ -909,6 +946,7 @@
> >      fname = server_root_relative(p, fname);
> >
> >      if (!(strcmp(fname, server_root_relative(p, RESOURCE_CONFIG_FILE))) ||
> > +     !(strcmp(fname, server_root_relative(p, SERVER_CONFIG_FILE)))   ||
>
> Ahh! So you can now start apache with none of the default config locations!
> Just a bunch of "-c directive" switches?

Yup, or just one, e.g.

 httpd -C "PerlModule Apache::httpd_conf"

-Doug


Re: [PATCH] add -C and -c switches (take 2)

Posted by Martin Kraemer <Ma...@mch.sni.de>.
On Wed, Jan 07, 1998 at 09:08:29PM +1300, Doug MacEachern wrote:
> +    fprintf(stderr, "Usage: %s [-d directory] [-f file] [-C|-c command] [-v] [-h] [-l]\n", bin);
> ...
> +    fprintf(stderr, "-C command : process command before reading config files\n");
> +    fprintf(stderr, "-c command : process command after reading config files\n");

Shouldn't "command" be called "directive"?

> +void process_command_config(server_rec *s, array_header *arr, pool *p, pool *ptemp)
> +{
> ...
> +#ifdef MOD_PERL
> +	if(!(strncmp(line, "PerlModule ", 11))) {
> ...
> +	    errmsg = perl_cmd_module(&parms, s->lookup_defaults, line);
> +
> +	    if (!errmsg)
> +		continue;

Does perl_cmd_module() print the errmsg string already? And are
the returned errors assumed to be non-fatal?

> +	}
> +#endif

>  void process_resource_config(server_rec *s, char *fname, pool *p, pool *ptemp)
>  {
>      const char *errmsg;
> @@ -909,6 +946,7 @@
>      fname = server_root_relative(p, fname);
>  
>      if (!(strcmp(fname, server_root_relative(p, RESOURCE_CONFIG_FILE))) ||
> +	!(strcmp(fname, server_root_relative(p, SERVER_CONFIG_FILE)))   ||

Ahh! So you can now start apache with none of the default config locations!
Just a bunch of "-c directive" switches?
Then I guess it's time to complement the AccessConfig, ResourceConfig
and TypesConfig directives with a new
   ServerConfig <path>
directive (well, not really, because we have the "-f serverconfig" switch).

Good! +1 from here,

    Martin
-- 
| S I E M E N S |  <Ma...@mch.sni.de>  |      Siemens Nixdorf
| ------------- |   Voice: +49-89-636-46021     |  Informationssysteme AG
| N I X D O R F |   FAX:   +49-89-636-44994     |   81730 Munich, Germany
~~~~~~~~~~~~~~~~My opinions only, of course; pgp key available on request

Re: [PATCH] add -C and -c switches (take 2)

Posted by Ben Laurie <be...@algroup.co.uk>.
Doug MacEachern wrote:
> 
> okay, here it is again now using array_header's.  This patch also
> includes a special check for PerlModule #ifdef MOD_PERL until I figure
> out the real problem.  The problem I mentioned yesterday only happens
> when no .conf files are read and PerlModule bootstraps the
> "<Perl></Perl>" section itself so all config can be read from the
> %Apache::ReadConfig:: symbol table.   The #ifdef MOD_PERL bit cures this
> problem.

+1 (untested).

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Re: [PATCH] add -C and -c switches (take 2)

Posted by Martin Kraemer <Ma...@mch.sni.de>.
On Fri, Jan 09, 1998 at 09:03:45AM +1300, Doug MacEachern wrote:
> 
> Should we only do the
> !(strcmp(fname, server_root_relative(p, SERVER_CONFIG_FILE)))
> check
> if(server_pre_read_config->nelts || server_post_read_config->nets) ?

Yes, that looks like a sensible precondition. Ben came to the same solution
(in Message-Id: <34...@algroup.co.uk>).
+1 to add this test.

    Martin
-- 
| S I E M E N S |  <Ma...@mch.sni.de>  |      Siemens Nixdorf
| ------------- |   Voice: +49-89-636-46021     |  Informationssysteme AG
| N I X D O R F |   FAX:   +49-89-636-44994     |   81730 Munich, Germany
~~~~~~~~~~~~~~~~My opinions only, of course; pgp key available on request

Re: [PATCH] add -C and -c switches (take 2)

Posted by Doug MacEachern <do...@telebusiness.co.nz>.
Martin Kraemer wrote:

> On Wed, Jan 07, 1998 at 09:08:29PM +1300, Doug MacEachern wrote:
> >
> >      if (!(strcmp(fname, server_root_relative(p, RESOURCE_CONFIG_FILE))) ||
> > +     !(strcmp(fname, server_root_relative(p, SERVER_CONFIG_FILE)))   ||
> >       !(strcmp(fname, server_root_relative(p, ACCESS_CONFIG_FILE)))) {
> >       if (stat(fname, &finfo) == -1)
> >           return;
> What happens now when none of the three default config files is available?
> Does apache still complain? Or does it silently try to start with its
> defaults (and complain that no ServerName is set or anything)? I didn't
> try your patch myself.

apache will complain:
% ./apache_1.3b4-dev/src/httpd
fopen: No such file or directory
httpd: could not open error log file /usr/local/apache/logs/error_log.

Should we only do the
!(strcmp(fname, server_root_relative(p, SERVER_CONFIG_FILE)))
check
if(server_pre_read_config->nelts || server_post_read_config->nets) ?

-Doug


Re: [PATCH] add -C and -c switches (take 2)

Posted by Ben Laurie <be...@algroup.co.uk>.
Martin Kraemer wrote:
> 
> On Wed, Jan 07, 1998 at 09:08:29PM +1300, Doug MacEachern wrote:
> >
> >      if (!(strcmp(fname, server_root_relative(p, RESOURCE_CONFIG_FILE))) ||
> > +     !(strcmp(fname, server_root_relative(p, SERVER_CONFIG_FILE)))   ||
> >       !(strcmp(fname, server_root_relative(p, ACCESS_CONFIG_FILE)))) {
> >       if (stat(fname, &finfo) == -1)
> >           return;
> What happens now when none of the three default config files is available?
> Does apache still complain? Or does it silently try to start with its
> defaults (and complain that no ServerName is set or anything)? I didn't
> try your patch myself.

I guess there have to be precommands if httpd.conf is missing.

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Re: [PATCH] add -C and -c switches (take 2)

Posted by Martin Kraemer <Ma...@mch.sni.de>.
On Wed, Jan 07, 1998 at 09:08:29PM +1300, Doug MacEachern wrote:
>  
>      if (!(strcmp(fname, server_root_relative(p, RESOURCE_CONFIG_FILE))) ||
> +	!(strcmp(fname, server_root_relative(p, SERVER_CONFIG_FILE)))   ||
>  	!(strcmp(fname, server_root_relative(p, ACCESS_CONFIG_FILE)))) {
>  	if (stat(fname, &finfo) == -1)
>  	    return;
What happens now when none of the three default config files is available?
Does apache still complain? Or does it silently try to start with its
defaults (and complain that no ServerName is set or anything)? I didn't
try your patch myself.

    Martin
-- 
| S I E M E N S |  <Ma...@mch.sni.de>  |      Siemens Nixdorf
| ------------- |   Voice: +49-89-636-46021     |  Informationssysteme AG
| N I X D O R F |   FAX:   +49-89-636-44994     |   81730 Munich, Germany
~~~~~~~~~~~~~~~~My opinions only, of course; pgp key available on request