diff options
Diffstat (limited to 'lib/JWebmail/Model/ReadMails/QMailAuthuser.pm')
-rw-r--r-- | lib/JWebmail/Model/ReadMails/QMailAuthuser.pm | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/JWebmail/Model/ReadMails/QMailAuthuser.pm b/lib/JWebmail/Model/ReadMails/QMailAuthuser.pm index b2015aa..5190e26 100644 --- a/lib/JWebmail/Model/ReadMails/QMailAuthuser.pm +++ b/lib/JWebmail/Model/ReadMails/QMailAuthuser.pm @@ -4,6 +4,8 @@ use v5.24; use warnings; use utf8; +use JWebmail::Config 'MAILDIR_EXTRACTOR'; + use IPC::Open2; use JSON::PP 'decode_json'; use Params::Check 'check'; @@ -11,7 +13,6 @@ use Role::Tiny::With; use Scalar::Util 'blessed'; use namespace::clean; -use JWebmail::Config 'MAILDIR_EXTRACTOR'; with 'JWebmail::Model::ReadMails::Role'; @@ -74,9 +75,9 @@ package JWebmail::Model::ReadMails::QMailAuthuser::Error { my $QMailAuthuserCheck = { - virtual_user => {required => 1}, - mailbox_path => {required => 1}, - qmail_dir => {default => '/var/qmail/'}, + virtual_user => {required => 1}, + mailbox_path => {required => 1}, + authenticator => {required => 1}, }; sub new { @@ -174,12 +175,12 @@ sub build_arg { my $self = shift; my ($user_mail_addr, $mode, $args) = @_; - return $self->{qmail_dir} . "/bin/qmail-authuser true 3<&0" + return $self->{authenticator} . ' true 3<&0' if $mode eq 'auth'; my ($user_name) = $user_mail_addr =~ /(\w*)@/; - return $self->{qmail_dir}.'/bin/qmail-authuser ' + return $self->{authenticator} . ' ' . join(' ', map { my $x = s/(['\\])/\\$1/gr; "'$x'" } ($self->{prog}, $self->{mailbox_path}, $self->{virtual_user}, $user_name, $mode, @$args)) . ' 3<&0'; } @@ -210,11 +211,6 @@ sub read_qmauth { my $rs; if (eof $reader) { - # for regular open - close $reader - or warn "closing read pipe failed: $!"; - $rs = $?; - # for IPC::Open2 if (waitpid($pid, 0) == $pid) { $rs = $?; @@ -244,18 +240,19 @@ sub read_qmauth { }; } elsif ($rs == 3 << 8 || $rs == 0) { + $rc = $rs >> 8; eval { $resp = decode_json $input if $input; 1 } or do { $resp = { info => "error decoding response", response => $input, cause => $@, - return_code => $rs >> 8, + return_code => $rc, }; - $rc = 3; }; } else { + $rc = $rs >> 8; $resp = { info => "got unsuccessful return code by qmail-authuser", return_code => $rc, |