From 2979c52b475533ce1fdff235800fb7d550806a29 Mon Sep 17 00:00:00 2001 From: Peter A Eisch Date: Wed, 9 Dec 2009 06:52:33 +0800 Subject: Adds the ability to have multiple instances (each with different configs) running under Apache. --- lib/Apache/Qpsmtpd.pm | 35 ++++++++++++++++++++++++++++++++++- 1 files changed, 34 insertions(+), 1 deletions(-) diff --git a/lib/Apache/Qpsmtpd.pm b/lib/Apache/Qpsmtpd.pm index f03e430..4281670 100644 --- a/lib/Apache/Qpsmtpd.pm +++ b/lib/Apache/Qpsmtpd.pm @@ -43,6 +43,25 @@ package Qpsmtpd::Apache; use Qpsmtpd::Constants; use base qw(Qpsmtpd::SMTP); +my %cdir_memo; + +sub config_dir { + my ($self, $config) = @_; + if (exists $cdir_memo{$config}) { + return $cdir_memo{$config}; + } + + if (uc($ENV{QPSMTPD_CONFIG}) eq 'USE-VIRTUAL-DOMAINS') { + my $cdir = $self->{conn}->base_server->dir_config("qpsmtpd.config_dir"); + $cdir =~ /^(.*)$/; # detaint + my $configdir = $1 if -e "$1/$config"; + $cdir_memo{$config} = $configdir; + } else { + $cdir_memo{$config} = SUPER::config_dir(@_); + } + return $cdir_memo{$config}; +} + sub start_connection { my $self = shift; my %opts = @_; @@ -183,6 +202,19 @@ Apache::Qpsmtpd - a mod_perl-2 connection handler for qpsmtpd PerlSetVar qpsmtpd.loglevel 4 +Using multiple instances of Qpsmtpd on the same server is also +possible by setting: + + $ENV{QPSMTPD_CONFIG} = "USE-VIRTUAL-DOMAINS"; + +Then in the VirtualHost of each config define the configuration +directory: + + PerlSetVar qpsmtpd.config_dir /path/to/qpsmtpd/config + +Several different configurations can be running on the same +server. + =head1 DESCRIPTION This module implements a mod_perl/apache 2.0 connection handler @@ -208,6 +240,7 @@ connections, but could do with some enhancements specific to SMTP. Matt Sergeant, Some credit goes to for Apache::SMTP which gave -me the inspiration to do this. +me the inspiration to do this. added the virtual +host support. =cut -- 1.7.2.2