Dnia 16.08.2022 o godz. 23:37:05 Aki Tuomi pisze:>
> doveadm_password = secret
>
> service doveadm {
> inet_listener http {
> port = 8080
> }
> }
>
> should allow you to use `who` command over HTTP API.
It's an interesting option, but after looking into "doveadm"
source code I
was able to reimplement the query that "doveadm who" does with a few
lines
of simple Perl code. It's exactly what I want, as it can be easily
integrated into a policy service written in Perl.
Thanks again for pointing me in the right direction.
If anybody is interested, here's the code:
#!/usr/bin/perl
use IO::Socket::UNIX qw( SOCK_STREAM );
$sockpath="/var/run/dovecot/anvil";
my $socket = IO::Socket::UNIX->new(
Type => SOCK_STREAM,
Peer => $sockpath,
)
or die("Can't connect to $sockpath");
$ANVIL_HANDSHAKE="VERSION\tanvil\t1\t0\n";
$ANVIL_CMD=$ANVIL_HANDSHAKE."CONNECT-DUMP\n";
$socket->send($ANVIL_CMD) or die "Socket write error";
$socket->recv($buffer, 65536, 0) or die "Socket read error";
chomp($buffer);
close($socket);
@lines=split(/\n/, $buffer);
foreach $line (@lines) {
#print "$line\n";
if ($line =~ m#^imap/([0-9A-Fa-f.:]+)/([^\t]+)\t#) {
print "IP=$1 user=$2\n";
}
}
--
Regards,
Jaroslaw Rafa
raj at rafa.eu.org
--
"In a million years, when kids go to school, they're gonna know: once
there
was a Hushpuppy, and she lived with her daddy in the Bathtub."