From 1a1dcc3e5302983d73a41e3db8bf99abb79fa44e Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Mon, 21 May 2012 16:11:49 -0400 Subject: [PATCH] auth: eval 'use' so plugins can be enabled by default and tested. --- config.sample/plugins | 4 ++++ config.sample/smtpauth-checkpassword | 1 + plugins/auth/auth_vpopmail | 4 ++-- plugins/auth/auth_vpopmail_sql | 9 ++++++++- 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 config.sample/smtpauth-checkpassword diff --git a/config.sample/plugins b/config.sample/plugins index bbcf50a..fe51829 100644 --- a/config.sample/plugins +++ b/config.sample/plugins @@ -45,6 +45,10 @@ check_spamhelo # sender_permitted_from # greylisting p0f genre,windows +auth/auth_checkpassword checkpw /usr/local/vpopmail/bin/vchkpw true /usr/bin/true +auth/auth_vpopmail +auth/auth_vpopmaild +auth/auth_vpopmail_sql auth/auth_flat_file auth/authdeny diff --git a/config.sample/smtpauth-checkpassword b/config.sample/smtpauth-checkpassword new file mode 100644 index 0000000..a029f3d --- /dev/null +++ b/config.sample/smtpauth-checkpassword @@ -0,0 +1 @@ +/usr/local/vpopmail/bin/vchkpw /bin/true diff --git a/plugins/auth/auth_vpopmail b/plugins/auth/auth_vpopmail index 43720c6..91a5ac6 100644 --- a/plugins/auth/auth_vpopmail +++ b/plugins/auth/auth_vpopmail @@ -45,7 +45,7 @@ use warnings; use Qpsmtpd::Auth; use Qpsmtpd::Constants; -#use vpopmail; # we eval this in $test_vpopmail +#use vpopmail; # we eval this in $test_vpopmail_module sub register { my ($self, $qp) = @_; @@ -86,7 +86,7 @@ sub test_vpopmail_module { my $self = shift; # vpopmail will not allow vauth_getpw to succeed unless the requesting user is vpopmail or root. # by default, qpsmtpd runs as the user 'qpsmtpd' and does not have permission. - eval "use vpopmail"; + eval 'use vpopmail'; if ( $@ ) { $self->log(LOGERROR, "skip: is vpopmail perl module installed?"); return; diff --git a/plugins/auth/auth_vpopmail_sql b/plugins/auth/auth_vpopmail_sql index ca00531..dd9b3cb 100644 --- a/plugins/auth/auth_vpopmail_sql +++ b/plugins/auth/auth_vpopmail_sql @@ -69,11 +69,18 @@ use warnings; use Qpsmtpd::Auth; use Qpsmtpd::Constants; -use DBI; +#use DBI; # done in ->register sub register { my ( $self, $qp ) = @_; + eval 'use DBI'; + if ( $@ ) { + warn "plugin disabled. is DBI installed?\n"; + $self->log(LOGERROR, "skip: plugin disabled. is DBI installed?\n"); + return; + }; + $self->register_hook('auth-plain', 'auth_vmysql'); $self->register_hook('auth-login', 'auth_vmysql'); $self->register_hook('auth-cram-md5', 'auth_vmysql');