This is something I've been patching into Debian's qpsmtpd for a while, since
it provides a cleaner way to override the distributed plugins than to replace
them (where they'll cause problems on upgrades.) It's also necessary for LFS
compliance, placing the plugins over under /usr/share instead of
homedir-relative.
Here's the patch involved (marked as for 0.30rc2, but it applies to 0.32 with
just a little fuzz). It doesn't work entirely properly -- it can trigger
infinite recursion if plugins are actually present in more than one directory,
IIRC (can't recall for sure, I haven't touched it in a while.)
--
Devin \ aqua(at)devin.com, IRC:Requiem; http://www.devin.com
Carraway \ 1024D/E9ABFCD2: 13E7 199E DD1E 65F0 8905 2E43 5395 CA0D E9AB FCD2
#! /bin/sh /usr/share/dpatch/dpatch-run
## 99-unnamed.dpatch by <[EMAIL PROTECTED]>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.
@DPATCH@
diff -aruN qpsmtpd-0.30rc2.multiinterface/lib/Qpsmtpd.pm
qpsmtpd-0.30rc2.config-plugindirs/lib/Qpsmtpd.pm
--- qpsmtpd-0.30rc2.multiinterface/lib/Qpsmtpd.pm 2005-07-01
19:08:37.000000000 -0700
+++ qpsmtpd-0.30rc2.config-plugindirs/lib/Qpsmtpd.pm 2005-07-05
16:48:21.000000000 -0700
@@ -19,14 +19,18 @@
my $configdir = $self->config_dir("logging");
my $configfile = "$configdir/logging";
my @loggers = $self->_config_from_file($configfile,'logging');
- my $dir = $self->plugin_dir;
- $self->_load_plugins($dir, @loggers);
-
- foreach my $logger (@loggers) {
- $self->log(LOGINFO, "Loaded $logger");
- }
+ $configdir = $self->config_dir('plugin_dirs');
+ $configfile = "$configdir/plugin_dirs";
+ my @plugin_dirs = $self->_config_from_file($configfile,'plugin_dirs');
+ for my $dir (@plugin_dirs) {
+ my @loaded = $self->_load_plugins($dir, @loggers);
+ foreach my $logger (@loaded) {
+ $self->log(LOGINFO, "Loaded $logger");
+ }
+ }
+
return @loggers;
}
@@ -117,9 +121,15 @@
return $configdir;
}
-sub plugin_dir {
- my ($name) = ($0 =~ m!(.*?)/([^/]+)$!);
- my $dir = "$name/plugins";
+sub plugin_dirs {
+ my $self = shift;
+ my @plugin_dirs = $self->config('plugin_dirs');
+
+ unless (@plugin_dirs) {
+ my ($name) = ($0 =~ m!(.*?)/([^/]+)$!);
+ @plugin_dirs = ( "$name/plugins" );
+ }
+ return @plugin_dirs;
}
sub get_qmail_config {
@@ -174,13 +184,14 @@
$self->{hooks} = {};
my @plugins = $self->config('plugins');
+ my @loaded;
- my $dir = $self->plugin_dir;
- $self->log(LOGNOTICE, "loading plugins from $dir");
+ for my $dir ($self->plugin_dirs) {
+ $self->log(LOGNOTICE, "loading plugins from $dir");
+ push @loaded, $self->_load_plugins($dir, @plugins);
+ }
- @plugins = $self->_load_plugins($dir, @plugins);
-
- return @plugins;
+ return @loaded;
}
sub _load_plugins {