From 0b38c21f401425807ae05dc35c3d3ff3aa753c3f Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Mon, 15 Sep 2014 13:32:52 -0700 Subject: [PATCH] auth_vpopmail_sql: wrap DB connect attempt in eval --- plugins/auth/auth_vpopmail_sql | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/auth/auth_vpopmail_sql b/plugins/auth/auth_vpopmail_sql index b561cd3..4c1d6a1 100644 --- a/plugins/auth/auth_vpopmail_sql +++ b/plugins/auth/auth_vpopmail_sql @@ -94,8 +94,11 @@ sub get_db_handle { my $dbuser = $self->qp->config("vpopmail_mysql_user") || "vpopmailuser"; my $dbpass = $self->qp->config("vpopmail_mysql_pass") || "vpoppasswd"; - my $dbh = DBI->connect($dsn, $dbuser, $dbpass) or do { - $self->log(LOGERROR, "skip: db connection failed"); + my $dbh; + eval { $dbh = DBI->connect($dsn, $dbuser, $dbpass); }; + if (!$dbh) { + $self->log(LOGERROR, "skip: db connection failed: $!"); + $self->log(LOGERROR, $@) if $@; return; }; $dbh->{ShowErrorStatement} = 1;