http_config plugin

other minor changes

update STATUS and Changes


git-svn-id: https://svn.perl.org/qpsmtpd/trunk@96 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Ask Bjørn Hansen 2002-11-06 06:42:55 +00:00
parent 9d5610a80a
commit f9113eb73a
4 changed files with 73 additions and 1 deletions

15
Changes
View File

@ -1,3 +1,18 @@
0.20 - development
Store hooks runtime config globally so they will work within the
transaction objects too.
content_log plugin - log the content of all mails for
debugging. Robert Spier <robert@perl.org>.
http_config plugin - get configuration via http
plugins can take arguments via their line in the "plugins" file
make the quit_fortune plugin check that the fortune program exists
0.12 - 2002/10/17
Better error messages when a plugin fails

2
STATUS
View File

@ -12,6 +12,8 @@ plugin support;
plugin access to the data line by line during the DATA phase
(instead of just after)
if qmail-queue can't be loaded we still return 250 ?!
TRACE in Constants.pm is not actually being used. Should it be?

50
plugins/http_config Normal file
View File

@ -0,0 +1,50 @@
=head1 NAME
http_config
=head1 DESCRIPTION
Example config plugin. Gets configuration data via http requests.
=head1 CONFIG
http_config is configured at plugin loading time via the plugins
config. Load the plugin with a list of urls like the folllowing.
http_config http://localhost/~smtpd/config/ http://www.example.com/cgi-bin/qp?config=
Looking to config "me", qpsmtpd will try loading
http://localhost/~smtpd/config/me and if failing that then try
http://www.example.com/cgi-bin/qp?config=me
=head1 BUGS
http_config doesn't do any caching. It should do some simple caching
to be used in production.
=cut
use LWP::Simple qw(get);
my @urls;
sub register {
my ($self, $qp, @args) = @_;
@urls = @args;
$self->register_hook("config", "http_config");
}
sub http_config {
my ($self, $transaction, $config) = @_;
$self->log(0, "http_config called with $config");
for my $url (@urls) {
$self->log(10, "http_config loading from $url");
my @config = split /[\r\n]+/, (get "$url$config" || "");
chomp @config;
@config = grep { $_ and $_ !~ m/^\s*#/ and $_ =~ m/\S/ } @config;
close CF;
$self->log(0, "returning http_config for $config ",Data::Dumper->Dump([\@config], [qw(config)]));
return (OK, @config) if @config;
}
return DECLINED;
}

View File

@ -10,7 +10,12 @@ sub quit_handler {
# fun, so skip it.
return (DECLINED) if ($qp->connection->hello || '') eq "ehlo";
my @fortune = `/usr/games/fortune -s`;
my $fortune = '/usr/games/fortune';
return DECLINED unless -e $fortune;
# local %ENV = ();
my @fortune = `$fortune -s`;
@fortune = map { chop; s/^/ \/ /; $_ } @fortune;
$qp->respond(221, $qp->config('me') . " closing connection.", @fortune);
return DONE;