summaryrefslogtreecommitdiff
path: root/lib/JWebmail/Model/ReadMails/QMailAuthuser.pm
diff options
context:
space:
mode:
authorJannis M. Hoffmann <jannis@fehcom.de>2023-09-10 15:39:25 +0200
committerJannis M. Hoffmann <jannis@fehcom.de>2023-09-10 15:39:25 +0200
commit278b76fabf31abe8fc4fbe6ca1c0ad6af830fcb7 (patch)
treea3ca8baafd3c26b6d8df3840fe92f5e2f2dd0c34 /lib/JWebmail/Model/ReadMails/QMailAuthuser.pm
parent84186e77461ddeb867fa2944dcbf45217b41b80e (diff)
added test pam to replace MockMaildir ReadMail implementation
Diffstat (limited to 'lib/JWebmail/Model/ReadMails/QMailAuthuser.pm')
-rw-r--r--lib/JWebmail/Model/ReadMails/QMailAuthuser.pm23
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,