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...@covalent.net> on 2000/04/27 00:11:45 UTC
vs. external config
i'm behind on reading the list, but seeing a few threads about mod_perl's
<Perl> configuration mechanism vs. using an external config generator.
i'll try to give some reasons why <Perl> config is more valuable that an
external generator.
first of all, in terms of Perl, <Perl> sections provide a "standard" way
of generating configuration. if you take that away, not only do you break
the hell out of existing systems, everybody ends up with their own
generator implementation that nobody else understands.
there is lots of info <Perl> sections can get at being inside the apache
runtime that external generators cannot, at least not in a clean way i can
think of. for example:
#whatever ServerRoot is already configured as or from -d
$ServerRoot = Apache->server_root_relative;
#now lots of things can be defined in terms of $ServerRoot
push @Alias,
["/icons/" => "$ServerRoot/icons"], ...
push @INC, "$ServerRoot/lib/perl"; #local Perl libraries
#httpd -DSSL
if (Apache->define('SSL')) {
#do ssl stuff
}
if (Apache->define('DEV')) {
unshift @INC, ... #point Perl's include path into your sandbox
}
#multiple developers running a server on the same box
#want to run the server as themselves for writability into
#their sandbox or whatever
#don't want to generate a dozen different config files to change this
#value, when it can just be in one file
$User = getpwuid $>;
$Group = getgrgid $);
$Port = $> + 1024; #choose a unique, unprivleged port based on user id
print "will listen on port $Port\n";
#similar thing, add some custom config without generting x different files
#and, what if there was no .httpd.conf and i add one, then i have to
#remember to re-generate the config, what a pain
if (-e "$ENV{HOME}/.httpd.conf") {
push @Include, "$ENV{HOME}/httpd.conf";
}
#nice, consistent api to virtual host config, don't have this api outside
#of httpd, would have to duplicate in some other module
#and, $s->log interface to ap_log_error, maybe syslog is turned on, maybe
#not. sure is nice to let apache take care of that for me
for (my $s = Apache->server; $s; $s = $s->next) {
unless (init_host(Server => $s->server_name)) {
email_alert(To => $s->server_admin);
$s->log->critical(...);
}
}
#get a database password without ever saving it to disk
#or keeping it around for long in memory
my $database_password = prompt("enter database password:");
connect_to_database($database_password);
undef $database_password;
$Apache::Server::SaveConfig = 1;
#by setting this variable, mod_perl does not clear the symbol table used
#to generate the config, and all these variables are available at request
#time in the Apache::ReadConfig:: namespace
#if httpd.conf were generated externally, i would need another way to make
#that config available to Perl code running inside the server
ok, thinking back to my first comment about everybody implementing their
own generator, i suppose people are suggesting mod_perl ship with a
generator. keeping in mind that the implementation of <Perl> config can
be sprinkled in with vanilla config in the same file, e.g.
LoadModule proxy_module libexec/libproxy.so
<Perl>
if (Apache->module('mod_proxy.c')) {
...
}
</Perl>
if Apache/mod_perl can no longer deal with <Perl> sections, that means
mod_perl has implement it's own config file parser, even though there's
already one inside httpd, that we can no longer use. this would be a
NIGHTMARE, how does mod_perl know if things are TAKE1, ITERATE, etc.??
so, if apache can no longer deal with handing <Perl> sections to mod_perl,
we loose a great deal of power, cleanliness, and have to duplicate heaps
of code that is already written, but can only be accessed inside apache
when it's running.
Re: mod_macro
Posted by Manoj Kasichainula <ma...@io.com>.
I'm not writing the code these days, so I'm not going to spend much
more time arguing this; if we haven't been able to convince each other
until now, no amount of back-and-forth will resolve this. And the holy
grail of cleanup is Apache 3.0 anyway :).
On Sun, May 14, 2000 at 12:14:58PM -0400, rbb@covalent.net wrote:
> Yes Manoj, you are correct, duplicating function is a bad thing. However,
> we have yet to find a solution that provides as much flexibility as what
> we currently have in 1.3 using external solutions. If you can provide the
> same function in 2.0 as we currently have in 1.3, we are all willing to
> listen. However every comment you have made on this has caused mod_perl
> to either lose functionality, or the mod_perl parser has to be able to not
> only parse perl, but also all of the httpd.conf file.
OK, now that I've had some time to think about it, I think I have a
solution that's less radical than my earlier proposals and covers all
of the cases that Doug described one: the per-request configuration
case. That is essentially dynamic configuration. Dynamic
configuration was out of the scope of the original config modules
design or of my suggestions. If dynamic configuration is the reason
for mod_perl to have a configuration engine, then let loose. Anyway:
If
httpd -f "| /blah/blah/httpdconfig.pl"
is supported, then you can embed Perl anywhere in your
configuration, because rather than wrapping Perl code in an Apache
config file, you can wrap an Apache config file with Perl code.
--- begin ---
#!/usr/bin/perl
my $serverroot = "/usr/local/apache";
print <<EOF
ServerType standalone
ServerRoot $serverroot
<Directory $serverroot/htdocs>
blahblah
</Directory>
EOF
system("cat", "existingconffile");
&name_vhost_section("perl.apache.org", "63.211.145.10");
&name_vhost_section("httpd.apache.org", "63.211.145.10");
# So sue me; I haven't written enough Perl that does subroutines for
# this to be syntactically correct
sub &name_vhost_section {
my ($hostname, $ipaddr) = @_;
print "<VirtualHost $ipaddr>\n";
print "ServerName $hostname\n;
print "etc.";
}
# and so on...
--- end ---
Perl modules (.pm files) can solve the problem of how to share
vars between an Apache module written in Perl and vars in the
configuration; just use the .pm in both. Or a "do" statement would
work; I'm sure that There's More Than One Way To Do It, but I'm not
the Perl uberdude here.
There are no generated files on the hard drive, because now we're
using a pipe to read in the configuration. But the option is still
available for admins to use an intermediate file if they want.
No parsing of Apache configuration is necessary. Any var that is
necessary for use in other parts of configuration should be set as I
set $serverroot above.
Did I miss anything?
> I am not worried about this code fitting into the cache either,
> because this is configuration code. It shouldn't be run often on a
> running server, and if it is slow, that isn't a big hit in the
> scheme of things.
OK, the cache example wasn't a very good one for this case. :) Sorry,
I'm not as good at this as Dean, yet.
My primary goal here is dead simple code everywhere. Whether the
internal config tree structure actually support mod_macro or mod-perl
style configuration is almost secondary to just making it no longer
necessary.
Re: mod_macro
Posted by Manoj Kasichainula <ma...@io.com>.
On Mon, May 15, 2000 at 09:47:46AM +0200, Fabien COELHO wrote:
> > Now we're getting into personal preference.
>
> Sure, but I gave a lot of time and sweat to m4 for this experience and
> preference;-)
I'm not a huge fan of m4 either (though my experience is primarily
from autoconf).
> The "conditional inclusion macros" or even "variables" job need
> assumptions about the lexical structure and grammar of the file processed,
> and they are quite different from one "language" to the other.
How come? I can't think of a reason, as long as you're using a
sufficient language. cpp isn't, m4 seems to be, a Perl script is.
> There is also a question of 'style'. Apache configuration file has a
> low-constraint line-oriented html-looking style, and it is an issue to
> provide tools compatible with this style.
I wouldn't think it would be hard to write a parser that grabbed all
instances of <Macro...> </Macro> and processed the contents.
> 'power' might also be considered. The issue is to match the need, not
> general purpose programming. So consider what are the problems that
> webmasters may have to face when configuring apache, and how to help them
> to handle these. If you use "m4", you have a full powered language at
> hand, which is not really needed for the average configuration file.
Well, when you have "function" calls, conditional execution, and
modularity through seperate files (as Apache + mod_macro has), you're
not that far off from a full-powered language.
> > My point is that Apache doesn't need to support IfDefine.
>
> Something as this one is really needed. It is used for conditionnal module
> loading.
This can be done with #ifdef in cpp or a standard conditional in m4.
> For instance, if you don't want the module which handles external
> filters;-)
You're funny. :)
> Also IfModule is alsoe needed and can only be done internally.
I have this nagging feeling that IfModule is just too dangerous anyway
without much benefit. If you "forget" to load a module, you get
directives which are ignored silently. It's useful as a way to allow
the standard distributed config file not to break, but other that
that, it seems to me that all it can do is hide errors from the
administrator, which isn't a good thing.
This is one of those cases though where I'd imagine there's some
legitimate use out there, but I just can't think of one other than for
making our current system of default config files work.
Re: mod_macro
Posted by Fabien COELHO <co...@cri.ensmp.fr>.
> > cpp: you cannot have multi line macros... so cpp macros are just useless.
>
> #include is there; but I can see that not being optimal.
Moreover there is no arguments to include.
> > m4: the quoting mecanism `' is horrible (from my poor experience).
>
> Now we're getting into personal preference.
Sure, but I gave a lot of time and sweat to m4 for this experience and
preference;-)
> If you don't like existing languages for doing conditional inclusion
> and macros, isn't it better to write an external filter to do this, so
> that all applications can benefit from a unified syntax?
Not necessarily. I don't think that one tool can solve every problem to
every taste. Otherwise everybody would use "m4" and be happy with it.
The "conditional inclusion macros" or even "variables" job need
assumptions about the lexical structure and grammar of the file processed,
and they are quite different from one "language" to the other. Thus it
often needs to be "particular" to the problem at hand. Thos explains why
cpp macros cannot be used for the line-oriented no-escape mecanism apache
configuration, although I'm very happy with these when I program in C.
There is also a question of 'style'. Apache configuration file has a
low-constraint line-oriented html-looking style, and it is an issue to
provide tools compatible with this style.
'power' might also be considered. The issue is to match the need, not
general purpose programming. So consider what are the problems that
webmasters may have to face when configuring apache, and how to help them
to handle these. If you use "m4", you have a full powered language at
hand, which is not really needed for the average configuration file.
> My point is that Apache doesn't need to support IfDefine.
Something as this one is really needed. It is used for conditionnal module
loading. For instance, if you don't want the module which handles external
filters;-) Also IfModule is alsoe needed and can only be done internally.
> Duplicating function that has already been written for us means more
> bugs, more complexity, more code (meaning less chance of fitting into
> cache as Dean always says). This affects everybody.
Macros processing and other configuration file utilities are only used at
startup, and is not likely to be used after that. Thus the pages holding
the code are more likely to stay on disk most of the time.
Sure, it's better to avoid code replication, what can be achieved by
better developper communication, a better documentation in and out of the
source code. Anyway, one must also solve the problems that need to be
solved...
--
Fabien.
Re: mod_macro
Posted by rb...@covalent.net.
> > Well, they are out at the time, and you don't have to use them if there
> > are in some day;-)
>
> Duplicating function that has already been written for us means more
> bugs, more complexity, more code (meaning less chance of fitting into
> cache as Dean always says). This affects everybody.
Yes Manoj, you are correct, duplicating function is a bad thing. However,
we have yet to find a solution that provides as much flexibility as what
we currently have in 1.3 using external solutions. If you can provide the
same function in 2.0 as we currently have in 1.3, we are all willing to
listen. However every comment you have made on this has caused mod_perl
to either lose functionality, or the mod_perl parser has to be able to not
only parse perl, but also all of the httpd.conf file.
Sometimes the only way to do something is to do it yopurself. I am not
worried about this code fitting into the cache either, because this is
configuration code. It shouldn't be run often on a running server, and if
it is slow, that isn't a big hit in the scheme of things.
Ryan
_______________________________________________________________________________
Ryan Bloom rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------
mod_macro
Posted by Manoj Kasichainula <ma...@io.com>.
On Thu, May 11, 2000 at 09:15:17AM +0200, Fabien COELHO wrote:
> cpp: you cannot have multi line macros... so cpp macros are just useless.
#include is there; but I can see that not being optimal.
> m4: the quoting mecanism `' is horrible (from my poor experience).
Now we're getting into personal preference. There are choices other
than m4 if you don't like its quoting mechanism. Perl is even quite
possible, especially with its <<EOF construct.
If you don't like existing languages for doing conditional inclusion
and macros, isn't it better to write an external filter to do this, so
that all applications can benefit from a unified syntax?
> > #ifdef SPOON
> > ServerRoot /spoon
> > #else
> > ServerRoot /fork
> > #endif
>
> <IfDefine SPOON> is already in, you don't need this;-)
My point is that Apache doesn't need to support IfDefine.
> Well, they are out at the time, and you don't have to use them if there
> are in some day;-)
Duplicating function that has already been written for us means more
bugs, more complexity, more code (meaning less chance of fitting into
cache as Dean always says). This affects everybody.
Re: vs. external config
Posted by Fabien COELHO <co...@cri.ensmp.fr>.
> > Also, the apache API does not provide sufficient hooks for configuration
> > file processing control.
>
> (Using cpp as the example, because I don't know enough m4)
>
> The only thing we need for this is the ability to read configuration
> from a pipe:
>
> httpd -f '| /lib/cpp /usr/local/apache/conf/httpd.conf'
>
> or whatever.
Sure. It looks good as an argument.
However I know about both cpp and m4. They may be quite powerfull, but
they can't do the expected job...
They need assumptions about the lexical or even the syntactic structure of
the file being processed, which are stronger than those actually used in
the httpd.conf format. Thus if you really want to use them, you have to
struggle with these assumptions with escapes of hacks or whatever. The
result is not very convincing, IMHO.
cpp: you cannot have multi line macros... so cpp macros are just useless.
m4: the quoting mecanism `' is horrible (from my poor experience).
> #ifdef SPOON
> ServerRoot /spoon
> #else
> ServerRoot /fork
> #endif
<IfDefine SPOON> is already in, you don't need this;-)
You also have Include, <IfModule ...>
> > On the other hand, I guess that the more standard the better, hence as
> > Apache does manage it's own configuration parsing, I would rather expect
> > it to provide the basic tools (macro, define, conditionnals, ...) needed
> > to improve the management of such files, which is quite important for
> > apache users, especially ISP. The current state is that some of them are
> > in, and some of them are out.
>
> Right. I'd prefer them all to be out. :)
Well, they are out at the time, and you don't have to use them if there
are in some day;-)
--
Fabien Coelho ___ coelho@cri.ensmp.fr ___ http://www.cri.ensmp.fr/~coelho
Re: vs. external config
Posted by Manoj Kasichainula <ma...@io.com>.
On Tue, May 09, 2000 at 11:20:23AM +0200, Fabien COELHO wrote:
> As for mod_macro, an internal support would be better, bacause there is no
> hook in apache to tell that a new configuration processing is started, and
> to attach per-configuration data, thus it relies on a hack to detect new
> configuration processings.
Sorry, I can't parse this.
> Also, the apache API does not provide sufficient hooks for configuration
> file processing control.
(Using cpp as the example, because I don't know enough m4)
The only thing we need for this is the ability to read configuration
from a pipe:
httpd -f '| /lib/cpp /usr/local/apache/conf/httpd.conf'
or whatever.
> EAPI includes one hook to filter lines, which
> was basically added for mod_define, and can basically only be used for
> such a functionnality.
#ifdef SPOON
ServerRoot /spoon
#else
ServerRoot /fork
#endif
> On the other hand, I guess that the more standard the better, hence as
> Apache does manage it's own configuration parsing, I would rather expect
> it to provide the basic tools (macro, define, conditionnals, ...) needed
> to improve the management of such files, which is quite important for
> apache users, especially ISP. The current state is that some of them are
> in, and some of them are out.
Right. I'd prefer them all to be out. :)
Re: vs. external config
Posted by Fabien COELHO <co...@cri.ensmp.fr>.
> > sure, but i have not been convinced the new way is better.
>
> Fair enough. Then backward-compatibility isn't the issue.
>
> > i don't see what the problem is with keeping the option open, so why take
> > it away?
>
> Well, if support for it doesn't change the config parser in any way
> (and Ryan assured me over beer that it doesn't), then I guess it's not
> a big deal. I'm basically reacting to the idea that we should actually
> add code to support modules like mod_macro, and perhaps mod_perl's
> configuration functions, if the work can be done just as well
> externally.
As for mod_macro, an internal support would be better, bacause there is no
hook in apache to tell that a new configuration processing is started, and
to attach per-configuration data, thus it relies on a hack to detect new
configuration processings.
Also, the apache API does not provide sufficient hooks for configuration
file processing control. EAPI includes one hook to filter lines, which
was basically added for mod_define, and can basically only be used for
such a functionnality. This would tend to suggest that other hooks are
needed if they are to be supported externally. However...
On the other hand, I guess that the more standard the better, hence as
Apache does manage it's own configuration parsing, I would rather expect
it to provide the basic tools (macro, define, conditionnals, ...) needed
to improve the management of such files, which is quite important for
apache users, especially ISP. The current state is that some of them are
in, and some of them are out.
If the thing is well defined and useful, the need for extra tools would be
greatly reduced, and particular and special needs can always be addressed
with external modules, as it is now anyway.
--
Fabien Coelho ___ coelho@cri.ensmp.fr ___ http://www.cri.ensmp.fr/~coelho
Re: vs. external config
Posted by Manoj Kasichainula <ma...@io.com>.
On Wed, Apr 26, 2000 at 06:30:15PM -0700, Doug MacEachern wrote:
> sure, but i have not been convinced the new way is better.
Fair enough. Then backward-compatibility isn't the issue.
> i don't see what the problem is with keeping the option open, so why take
> it away?
Well, if support for it doesn't change the config parser in any way
(and Ryan assured me over beer that it doesn't), then I guess it's not
a big deal. I'm basically reacting to the idea that we should actually
add code to support modules like mod_macro, and perhaps mod_perl's
configuration functions, if the work can be done just as well
externally.
<speech length=long>
There are numerous features that all servers that have configuration
files could use, such as being able to:
- include other files
- support macros
- support conditional evaluation
- get configuration from a db
- get configuration from an LDAP directory
- get configuration from ...
- generate configuration in Perl
- generate configuration in Python
- generate configuration in ...
If you have m such features, and n servers, the world has to expend
O(n*m) effort to add these features to every server. Wouldn't it be
nice if these features were included in separate tools, so that they'd
only be implemented O(m) times? You'd also require far less security
auditing and bug fixing, and people writing new servers (or any other
programs for that matter) could spend more time working on their own
specialized code, rather than solving problems that have already been
solved dozens of times in the past. And smaller pieces are easier to
maintain anyway. This is the goal of OO, but pulled out to the
tool level.
This is why I am strongly encouraging as much separation of features
into external commands as is possible without sacrificing genuinely
useful function.
</speech>
Re: vs. external config
Posted by Greg Stein <gs...@lyra.org>.
On Wed, 26 Apr 2000, Manoj Kasichainula wrote:
> On Wed, Apr 26, 2000 at 06:10:31PM -0700, Doug MacEachern wrote:
> > keyword: "Ours". that doesn't help people who already have their own and
> > would like to keep it that way.
>
> The whole purpose of a new major version is to have a chance to
> massively break compatibility if we think the new way of doing things
> is better.
hehe... :-)
Damn, man. You are leaving yourself *SO* wide open with that. :-) I don't
think it would be fair to respond...
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
Re: vs. external config
Posted by Doug MacEachern <do...@covalent.net>.
On Wed, 26 Apr 2000, Manoj Kasichainula wrote:
> The whole purpose of a new major version is to have a chance to
> massively break compatibility if we think the new way of doing things
> is better.
sure, but i have not been convinced the new way is better.
i'm sure there's other people using <Perl> config who would feel the same
way.
i don't see what the problem is with keeping the option open, so why take
it away? this is an area, unlike say, the new hook implementation, where
there can be more than one way of doing things. and in this particular
case, there's little effort/overhead/harm/etc in keeping the old way
available.
Re: vs. external config
Posted by Manoj Kasichainula <ma...@io.com>.
On Wed, Apr 26, 2000 at 06:10:31PM -0700, Doug MacEachern wrote:
> keyword: "Ours". that doesn't help people who already have their own and
> would like to keep it that way.
The whole purpose of a new major version is to have a chance to
massively break compatibility if we think the new way of doing things
is better.
Re: vs. external config
Posted by Doug MacEachern <do...@covalent.net>.
On Wed, 26 Apr 2000, Jim Winstead wrote:
> Ours is perl-based as well. Its very straightforward, but does
> some fun things like dynamically allocate ports for developer's
> sandboxes.
keyword: "Ours". that doesn't help people who already have their own and
would like to keep it that way.
Re: vs. external config
Posted by Greg Stein <gs...@lyra.org>.
On Wed, 26 Apr 2000, Jim Winstead wrote:
> On Apr 26, Manoj Kasichainula wrote:
> > With qmail-style configuration, we might be able to use symlinks. Or,
> > the external parser can easily do this task as well. In fact, the
> > sandboxing setup I'm working on at Collab uses an external parser
> > (Perl-based of course).
>
> I think everyone is required to write one of these at least once. :)
> Ours is perl-based as well. Its very straightforward, but does
> some fun things like dynamically allocate ports for developer's
> sandboxes.
>
> I can't see any advantage to doing this within the Apache process.
I've never written one. I've been running a dozen sites for four years and
never come close to it. I like the fact that I don't have to monkey with a
bunch of external crap. Gimme the functionality, make it easy, and don't
cover up the complexity with Yet More Tools.
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
Re: vs. external config
Posted by Jim Winstead <ji...@trainedmonkey.com>.
On Apr 26, Manoj Kasichainula wrote:
> With qmail-style configuration, we might be able to use symlinks. Or,
> the external parser can easily do this task as well. In fact, the
> sandboxing setup I'm working on at Collab uses an external parser
> (Perl-based of course).
I think everyone is required to write one of these at least once. :)
Ours is perl-based as well. Its very straightforward, but does
some fun things like dynamically allocate ports for developer's
sandboxes.
I can't see any advantage to doing this within the Apache process.
Jim
Re: vs. external config
Posted by Greg Stein <gs...@lyra.org>.
On Wed, 26 Apr 2000, Doug MacEachern wrote:
> Manoj wrote:
>...
> > If the accessibility of the rest of the Apache config is dead simple
> > (and I think that's mandatory for the external config parser idea to
> > work), then I don't think it's a burden for a webmaster to write his
> > own Perl code to fill in the missing details of an Apache config if he
> > was already planning to use embedded Perl in the config file anyway.
>
> again, how does the external parser know the parse rules defined in the
> command_rec's ? and again, i don't care how "simple" the config is to
> parse, there's already a parser inside Apache, i want to reuse it.
> along with reusing other pieces of the already defined/implemented api i
> pointed out.
Not only parse rules, but the semantics of mapping those arguments into
the internal configuration of Apache. For example:
Options MultiViews Indexes
<Directory /foo>
Options -Indexes
<Perl>
... line noise ...
</Perl>
</Directory>
How in the hell is the *external* processor supposed to figure out the
final value of the Options that apply inside that directory? Are you
saying the processor needs to replicate all the handling of the Options
statement? Cha, right. And monkeys are going to fly out of your butt. And
it isn't going to feel good...
> i don't understand what the problem is with leaving this option open. if
> you want to use an external parser/generator, fine. all apache has to do
> to maintain the other option is to allow a <Container> to contain an
> arbitrary chunk of text that is handled by a third-party module. where is
> the harm in that?
We don't need a Container module. This is easily handled by the type (1)
hook that I specified in my design note. Apache provides the hook and then
does nothing else. Simple as all hell for Apache -- we declare a hook,
implement it, and run it during the file processing. What is that? Three
lines of code using those AP_HOOK macros?
Tossing the requirement for external tools just to save a few lines of
code is so backwards, it is silly.
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
Re: vs. external config
Posted by Doug MacEachern <do...@covalent.net>.
> If you're worried about the case where only part of your configuration
> is generated by Perl, then the perl script can process the existing
> configuration easily, iff the httpd configuration syntax is stupidly
> easy to parse.
it doesn't matter to me how "easy" it is to parse, Apache already has a
config parser, i want to reuse that code. again, how do i know what the
parse rules are? TAKE1, TAKE2, TAKE3, ITERATE, etc., are all defined in
the command_rec, is the external parser expected to duplicate that info
for every module's command_rec ?
another area an external parser cannot deal with is generating config at
request time, based on info in the request_rec, which can be done with
<Perl> sections in .htaccess files.
> I don't see a problem with having lots of files around. It's not like
> config files are multi-megabyte or anything.
i'm not concerned with size, i'm concerned with the clutter of multiple
generated files.
> With qmail-style configuration, we might be able to use symlinks. Or,
> the external parser can easily do this task as well. In fact, the
> sandboxing setup I'm working on at Collab uses an external parser
> (Perl-based of course).
that's your sandboxing setup, other people already have their own based on
a simple mechanism that's been around for 3 years. i don't like the idea
of taking it away.
> I guess this one's kind of nice. But, I'd say that if you can't trust
> the filesystem permissions on your drive, I think you have bigger
> problems.
maybe, but that's your opinion (which i share, but), i'd like to leave the
decision to the users, not us.
> I don't quite understand this one. The current config isn't otherwise
> available to the Perl code right now? Well, this setup makes that
> easier. :)
what it means is that any variables defined in a <Perl> section are
available to Perl code running in that process. this allows Apache and
application code to share configuration without have to parse it twice
with two different parsers.
> If the accessibility of the rest of the Apache config is dead simple
> (and I think that's mandatory for the external config parser idea to
> work), then I don't think it's a burden for a webmaster to write his
> own Perl code to fill in the missing details of an Apache config if he
> was already planning to use embedded Perl in the config file anyway.
again, how does the external parser know the parse rules defined in the
command_rec's ? and again, i don't care how "simple" the config is to
parse, there's already a parser inside Apache, i want to reuse it.
along with reusing other pieces of the already defined/implemented api i
pointed out.
i don't understand what the problem is with leaving this option open. if
you want to use an external parser/generator, fine. all apache has to do
to maintain the other option is to allow a <Container> to contain an
arbitrary chunk of text that is handled by a third-party module. where is
the harm in that?
Re: vs. external config
Posted by Greg Stein <gs...@lyra.org>.
On Wed, 26 Apr 2000, Manoj Kasichainula wrote:
>...
> On Wed, Apr 26, 2000 at 03:11:45PM -0700, Doug MacEachern wrote:
> > first of all, in terms of Perl, <Perl> sections provide a "standard" way
> > of generating configuration. if you take that away, not only do you break
> > the hell out of existing systems, everybody ends up with their own
> > generator implementation that nobody else understands.
>
> I'm not talking at all about what's included with Apache, just what's
> in the httpd binary. I think it's next to mandatory that we include a
> default parser with Apache that will do DNS resolution and such.
See my other comments re: binary vs separate tool. We must write it, so
the division is purely artificial and contrived.
>...
> > there is lots of info <Perl> sections can get at being inside the apache
> > runtime that external generators cannot, at least not in a clean way i can
> > think of. for example:
> >
> > #whatever ServerRoot is already configured as or from -d
> > $ServerRoot = Apache->server_root_relative;
> >
> > #now lots of things can be defined in terms of $ServerRoot
> > push @Alias,
> > ["/icons/" => "$ServerRoot/icons"], ...
> >
> > push @INC, "$ServerRoot/lib/perl"; #local Perl libraries
>
> If your entire configuration is generated by a Perl script, it has
> this info anyway.
Bullshit. As Doug has said, to truly know this, the Perl script must not
only replicate the Apache parser, but it has to duplicate the *semantics*
of the directives. What argument formats? What ranges are used? How do
those arguments map into the configuration of a virtual server? How is the
nesting/overriding of values performed when a <Directory> is present? etc.
To require somebody to duplicate all of this knowledge into an external
tool, simply because you desire to have external tools, is totally
backwards.
>...
> > #multiple developers running a server on the same box
> > #want to run the server as themselves for writability into
> > #their sandbox or whatever
> > #don't want to generate a dozen different config files to change this
> > #value, when it can just be in one file
>
> I don't see a problem with having lots of files around. It's not like
> config files are multi-megabyte or anything.
You don't. I agree with Doug: I do. I have a dozen virtual hosts in my
httpd.conf. I keep them in one file for management simplicity. I like it
that way. Saying "sorry, that is no longer acceptable. you must use
'ApacheConfigSplitter' if you want a single file since Apache now requires
multiple files." Feh.
> > $User = getpwuid $>;
> > $Group = getgrgid $);
> > $Port = $> + 1024; #choose a unique, unprivleged port based on user id
> > print "will listen on port $Port\n";
>
> With qmail-style configuration, we might be able to use symlinks. Or,
> the external parser can easily do this task as well. In fact, the
Great! Make my job harder! Thank you!
</sarcasm> :-)
>...
> > #get a database password without ever saving it to disk
> > #or keeping it around for long in memory
> > my $database_password = prompt("enter database password:");
> > connect_to_database($database_password);
> > undef $database_password;
>
> I guess this one's kind of nice. But, I'd say that if you can't trust
> the filesystem permissions on your drive, I think you have bigger
> problems.
As Doug said. So? That's my policy and my problem :-)
>...
> > if (Apache->module('mod_proxy.c')) {
> > ...
> > }
>
> IfModule takes care of this. And the only good reason I can think of
> for IfModule anyway is to allow directives not to fail if they aren't
> present. That can better be done with an "optional" flag or something.
Optional flag? Eh? Can you explain this idea further?
[ I'm presuming the answer isn't that "the optional flag is in the
command_rec" since (by definition) the command_rec is not present. ]
> > </Perl>
> >
> > if Apache/mod_perl can no longer deal with <Perl> sections, that means
> > mod_perl has implement it's own config file parser
>
> If the accessibility of the rest of the Apache config is dead simple
> (and I think that's mandatory for the external config parser idea to
> work), then I don't think it's a burden for a webmaster to write his
> own Perl code to fill in the missing details of an Apache config if he
> was already planning to use embedded Perl in the config file anyway.
Why must I sprinkle all my configuration handling across httpd.conf,
mungeconfig.pl, and othermunger.pl?
Empirically-proven, the embedded configuration of mod_perl is useful.
(personally, I find Perl in any form blows, but can accept its utility :-)
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
Re: vs. external config
Posted by Manoj Kasichainula <ma...@io.com>.
You forced me to do some serious pondering. But I think I have
answers.
On Wed, Apr 26, 2000 at 03:11:45PM -0700, Doug MacEachern wrote:
> first of all, in terms of Perl, <Perl> sections provide a "standard" way
> of generating configuration. if you take that away, not only do you break
> the hell out of existing systems, everybody ends up with their own
> generator implementation that nobody else understands.
I'm not talking at all about what's included with Apache, just what's
in the httpd binary. I think it's next to mandatory that we include a
default parser with Apache that will do DNS resolution and such.
> there is lots of info <Perl> sections can get at being inside the apache
> runtime that external generators cannot, at least not in a clean way i can
> think of. for example:
>
> #whatever ServerRoot is already configured as or from -d
> $ServerRoot = Apache->server_root_relative;
>
> #now lots of things can be defined in terms of $ServerRoot
> push @Alias,
> ["/icons/" => "$ServerRoot/icons"], ...
>
> push @INC, "$ServerRoot/lib/perl"; #local Perl libraries
If your entire configuration is generated by a Perl script, it has
this info anyway.
If you're worried about the case where only part of your configuration
is generated by Perl, then the perl script can process the existing
configuration easily, iff the httpd configuration syntax is stupidly
easy to parse. I'm thinking something similar to qmail's config file
format, with a whole directory hierarchy organizing the data. So for
your example:
# yeah, there are far more efficient ways to do this, but this is just
# an example
$Serverroot = `cat /usr/local/apache/conf/serverroot`
or the -d argument to the parser, or whatever.
I want the output of the parser (i.e. the input to Apache) to be a
scripting-level API to the current Apache configuration. It has to be
dead simple, or else your concerns will make this unfeasible.
> #multiple developers running a server on the same box
> #want to run the server as themselves for writability into
> #their sandbox or whatever
> #don't want to generate a dozen different config files to change this
> #value, when it can just be in one file
I don't see a problem with having lots of files around. It's not like
config files are multi-megabyte or anything.
> $User = getpwuid $>;
> $Group = getgrgid $);
> $Port = $> + 1024; #choose a unique, unprivleged port based on user id
> print "will listen on port $Port\n";
With qmail-style configuration, we might be able to use symlinks. Or,
the external parser can easily do this task as well. In fact, the
sandboxing setup I'm working on at Collab uses an external parser
(Perl-based of course).
I'd give similar answers to your other cases.
> #get a database password without ever saving it to disk
> #or keeping it around for long in memory
> my $database_password = prompt("enter database password:");
> connect_to_database($database_password);
> undef $database_password;
I guess this one's kind of nice. But, I'd say that if you can't trust
the filesystem permissions on your drive, I think you have bigger
problems.
> $Apache::Server::SaveConfig = 1;
>
> #by setting this variable, mod_perl does not clear the symbol table used
> #to generate the config, and all these variables are available at request
> #time in the Apache::ReadConfig:: namespace
> #if httpd.conf were generated externally, i would need another way to make
> #that config available to Perl code running inside the server
I don't quite understand this one. The current config isn't otherwise
available to the Perl code right now? Well, this setup makes that
easier. :)
> ok, thinking back to my first comment about everybody implementing their
> own generator, i suppose people are suggesting mod_perl ship with a
> generator.
You're one step ahead of me.
> keeping in mind that the implementation of <Perl> config can
> be sprinkled in with vanilla config in the same file, e.g.
>
> LoadModule proxy_module libexec/libproxy.so
>
> <Perl>
>
> if (Apache->module('mod_proxy.c')) {
> ...
> }
IfModule takes care of this. And the only good reason I can think of
for IfModule anyway is to allow directives not to fail if they aren't
present. That can better be done with an "optional" flag or something.
> </Perl>
>
> if Apache/mod_perl can no longer deal with <Perl> sections, that means
> mod_perl has implement it's own config file parser
If the accessibility of the rest of the Apache config is dead simple
(and I think that's mandatory for the external config parser idea to
work), then I don't think it's a burden for a webmaster to write his
own Perl code to fill in the missing details of an Apache config if he
was already planning to use embedded Perl in the config file anyway.