From e2ddcfc51f66c2a52a401064eab005e793f148ee Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sun, 9 Dec 2018 18:41:06 +0100 Subject: Update 'IMAP', 'MSA' and 'LDAP-provider' roles to Debian Stretch. --- roles/IMAP/files/usr/local/bin/dovecot-auth-proxy.pl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'roles/IMAP/files/usr') diff --git a/roles/IMAP/files/usr/local/bin/dovecot-auth-proxy.pl b/roles/IMAP/files/usr/local/bin/dovecot-auth-proxy.pl index 399e65f..5b2c74e 100755 --- a/roles/IMAP/files/usr/local/bin/dovecot-auth-proxy.pl +++ b/roles/IMAP/files/usr/local/bin/dovecot-auth-proxy.pl @@ -74,15 +74,15 @@ sub server() { next; } # - unless ($1 == 2 and $2 == 0 and $3 == 0) { + unless ($1 == 2 and $2 == 1 and $3 == 0) { warn "Unsupported protocol version $1.$2 (or value type $3)\n"; close $conn or warn "Can't close: $!"; next; } my $cmd = $conn->getline() // ''; - if ($cmd =~ /\AI(\d+)\t(.*)\n\z/) { - iterate($conn, $1, $2); + if ($cmd =~ /\AI(\d+)\t(\d+)\t(.*)\n\z/) { + iterate($conn, $1, $2, $3); } else { fail($conn => "Unknown command line: $cmd"); @@ -98,8 +98,8 @@ sub fail($;$) { } # list all users, even the inactive ones -sub iterate($$$) { - my ($fh, $flags, $prefix) = @_; +sub iterate($$$$) { + my ($fh, $flags, $max_rows, $prefix) = @_; unless ($flags == 0) { fail($fh => "Unsupported iterate flags $flags"); return; @@ -109,17 +109,19 @@ sub iterate($$$) { fail($fh => "opendir: $!"); return; }; + my $count = 0; while (defined (my $d = readdir $dh)) { next if $d eq '.' or $d eq '..'; opendir my $dh, $d or do { fail($fh => "opendir: $!"); return; }; - while (defined (my $l = readdir $dh)) { + while (defined (my $l = readdir $dh) and ($max_rows <= 0 or $count < $max_rows)) { next if $l eq '.' or $l eq '..'; my $user = $l.'@'.$d; next unless $user =~ /\A[a-zA-Z0-9\.\-_@]+\z/; # skip invalid user names $fh->printf("O%s%s\t\n", $prefix, $user); + $count++; } closedir $dh or warn "closedir: $!"; } -- cgit v1.2.3