From e7ea7a09496af330267051878abc8fee08dd31d5 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Wed, 27 Mar 2013 19:37:40 -0400 Subject: [PATCH] dspam: catch error where QP user lacks x on dspam x = execute privileges --- plugins/dspam | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/dspam b/plugins/dspam index a7b7013..fe353ca 100644 --- a/plugins/dspam +++ b/plugins/dspam @@ -217,14 +217,26 @@ sub register { $self->{_args}{reject_type} ||= 'perm'; $self->{_args}{dspam_bin} ||= '/usr/local/bin/dspam'; - if ( ! -x $self->{_args}{dspam_bin} ) { - $self->log(LOGERROR, "dspam CLI binary not found: install dspam and/or set dspam_bin"); - return DECLINED; - }; + $self->get_dspam_bin() or return DECLINED; $self->register_hook('data_post', 'data_post_handler'); } +sub get_dspam_bin { + my $self = shift; + + my $bin = $self->{_args}{dspam_bin}; + if ( ! -e $bin ) { + $self->log(LOGERROR, "error, dspam CLI binary not found: install dspam and/or set dspam_bin"); + return; + }; + if ( ! -x $bin ) { + $self->log(LOGERROR, "error, no permission to run $bin"); + return; + }; + return $bin; +}; + sub data_post_handler { my $self = shift; my $transaction = shift || $self->qp->transaction;