From f9113eb73a815114769afc6c8ef6575a3d6ecf73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ask=20Bj=C3=B8rn=20Hansen?= Date: Wed, 6 Nov 2002 06:42:55 +0000 Subject: [PATCH] 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 --- Changes | 15 +++++++++++++ STATUS | 2 ++ plugins/http_config | 50 ++++++++++++++++++++++++++++++++++++++++++++ plugins/quit_fortune | 7 ++++++- 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 plugins/http_config diff --git a/Changes b/Changes index 0e5e58f..dbc30cc 100644 --- a/Changes +++ b/Changes @@ -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 . + + 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 diff --git a/STATUS b/STATUS index 3c92a0b..227da14 100644 --- a/STATUS +++ b/STATUS @@ -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? diff --git a/plugins/http_config b/plugins/http_config new file mode 100644 index 0000000..0018595 --- /dev/null +++ b/plugins/http_config @@ -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; +} diff --git a/plugins/quit_fortune b/plugins/quit_fortune index da06239..43bfaa1 100644 --- a/plugins/quit_fortune +++ b/plugins/quit_fortune @@ -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;