These 3 auth plugins all have a data store they fetch the reference password or hash from. They then match the attempted password or hash against the reference. This consolidates the latter portion (validating the password/hash) into Auth.pm.
* less duplicated code in the plugins. * Pass validation consistently handled for these 3 plugins. * less work to create similar auth plugins Qpsmtpd::Auth also caches the CRAM-MD5 ticket. It could also cache user/pass info if this was desirable. --- plugins/auth/auth_vpopmail | 4 ++-- plugins/auth/auth_vpopmail_sql | 9 ++++++++- t/plugin_tests/auth/auth_vpopmail_sql | 5 +++++ 3 files changed, 15 insertions(+), 3 deletions(-) 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'); diff --git a/t/plugin_tests/auth/auth_vpopmail_sql b/t/plugin_tests/auth/auth_vpopmail_sql index 0e6c84e..e61cad0 100644 --- a/t/plugin_tests/auth/auth_vpopmail_sql +++ b/t/plugin_tests/auth/auth_vpopmail_sql @@ -6,6 +6,11 @@ use warnings; sub register_tests { my $self = shift; + eval 'use DBI'; + if ( $@ ) { + warn "skipping auth_vpopmail_sql tests, is DBI installed?\n"; + return; + }; $self->register_test("auth_vpopmail_sql", 3); } -- 1.7.9.6