[Dovecot] how to talk with doveadmin unix socket
Hello,
I would like to get mailbox quota by doveadm unix socket (/var/run/dovecor/doveadm-server). I get from strace syntax of comunication:
write(9, "VERSION\t1\t0\nUSER\t1\tpiotr.rotter@active24.pl\tservice=doveadm\n", 60) = 60 read(9, "VERSION\t1\t1\nSPID\t20805\n", 8192) = 23 read(9, "USER\t1\tpiotr.rotter@active24.pl\temail=piotr.rotter@active24.pl\tclear=7T33z456\thome=/vm/08/A/active24.pl/piotr.rotter/\tuid=502\tgid=502\tquota_rule=*:storage=2097152000B\tquota_rule2=*:messages=50000\n", 8169) = 196
and I wrote super simple client in php:
<?php $sock = stream_socket_client('unix:///var/run/dovecot/doveadm-server', $errno, $errstr); fwrite($sock, "VERSION\t1\t0\nUSER\t1\tpiotr.rotter@active24.pl\tservice=doveadm\n"); echo fread($sock, 4096)."\n"; echo fread($sock, 4096)."\n"; fclose($sock); ?>
But i get only "+" sign and line in errorlog as below:
2013-02-28T00:39:56.377437+01:00 kurier9 dovecot: doveadm: Error: doveadm client not compatible with this server (mixed old and new binaries?)
I would be very grateful for your help with this problem, what I doing wrong.
My current dovecot version is 2.1.13
On Thu, Feb 28, 2013 at 1:53 AM, Piotr Rotter piotr.rotter@active24.plwrote:
Hello,
I would like to get mailbox quota by doveadm unix socket (/var/run/dovecor/doveadm-**server). I get from strace syntax of comunication:
write(9, "VERSION\t1\t0\nUSER\t1\tpiotr**.rotter@active24.pltpiotr.rotter@active24.pl \tservice=**doveadm\n", 60) = 60 read(9, "VERSION\t1\t1\nSPID\t20805\n"**, 8192) = 23 read(9, "USER\t1\tpiotr.rotter@**active24.pl tpiotr.rotter@active24.pl \temail=piotr.**rotter@active24.pl piotr.rotter@active24.pl\tclear=** 7T33z456\thome=/vm/08/A/active**24.pl/piotr.rotter/\tuid=502\** tgid=502\tquota_rule=*:**storage=2097152000B\tquota_** rule2=*:messages=50000\nhttp://active24.pl/piotr.rotter/%5Ctuid=502%5Ctgid=502%5Ctquota_rule=*:stora...", 8169) = 196
and I wrote super simple client in php:
<?php $sock = stream_socket_client('unix:///**var/run/dovecot/doveadm-**server', $errno, $errstr); fwrite($sock, "VERSION\t1\t0\nUSER\t1\tpiotr**.rotter@active24.pl<tpiotr.rotter@active24.pl> \tservice=**doveadm\n"); echo fread($sock, 4096)."\n"; echo fread($sock, 4096)."\n"; fclose($sock); ?>
But i get only "+" sign and line in errorlog as below:
2013-02-28T00:39:56.377437+01:**00 kurier9 dovecot: doveadm: Error: doveadm client not compatible with this server (mixed old and new binaries?)
I would be very grateful for your help with this problem, what I doing wrong.
My current dovecot version is 2.1.13
Here is my example on perl
socket(TSOCK, PF_UNIX, SOCK_STREAM,0);
connect(TSOCK, sockaddr_un("$conf{quota_socket}"));
if ($? != 0) {
#error here
}
#After connect on socket, dovecot returns "+" or "-". Just a simple
check for data. if (defined(my $answer = <TSOCK>)) {
print TSOCK "VERSION\tdoveadm-server\t1\t0\n";
print TSOCK "PLAIN\t$conf{'doveadm_password'}\n";
TSOCK->flush;
#'+' here
$answer=<TSOCK>;
print TSOCK "\t$local_part\@$domain\tquota get\n";
TSOCK->flush;
my $quota_data = <TSOCK>;
#"+" if everything is OK
$answer = <TSOCK>;
close TSOCK;
}
Don't forget to set doveadm_password= in dovecot config(clearttext) and you must encode password in base64 for using in a script (after PLAIN command).
PS dovecot version 2.1.15 here.
W dniu 28.02.2013 08:03, Nikita Koshikov pisze:
On Thu, Feb 28, 2013 at 1:53 AM, Piotr Rotter piotr.rotter@active24.plwrote:
Hello,
I would like to get mailbox quota by doveadm unix socket (/var/run/dovecor/doveadm-**server). I get from strace syntax of comunication:
write(9, "VERSION\t1\t0\nUSER\t1\tpiotr**.rotter@active24.pltpiotr.rotter@active24.pl \tservice=**doveadm\n", 60) = 60 read(9, "VERSION\t1\t1\nSPID\t20805\n"**, 8192) = 23 read(9, "USER\t1\tpiotr.rotter@**active24.pl tpiotr.rotter@active24.pl \temail=piotr.**rotter@active24.pl piotr.rotter@active24.pl\tclear=** 7T33z456\thome=/vm/08/A/active**24.pl/piotr.rotter/\tuid=502\** tgid=502\tquota_rule=*:**storage=2097152000B\tquota_** rule2=*:messages=50000\nhttp://active24.pl/piotr.rotter/%5Ctuid=502%5Ctgid=502%5Ctquota_rule=*:stora...", 8169) = 196
and I wrote super simple client in php:
<?php $sock = stream_socket_client('unix:///**var/run/dovecot/doveadm-**server', $errno, $errstr); fwrite($sock, "VERSION\t1\t0\nUSER\t1\tpiotr**.rotter@active24.pl<tpiotr.rotter@active24.pl> \tservice=**doveadm\n"); echo fread($sock, 4096)."\n"; echo fread($sock, 4096)."\n"; fclose($sock); ?>
But i get only "+" sign and line in errorlog as below:
2013-02-28T00:39:56.377437+01:**00 kurier9 dovecot: doveadm: Error: doveadm client not compatible with this server (mixed old and new binaries?)
I would be very grateful for your help with this problem, what I doing wrong.
My current dovecot version is 2.1.13
Here is my example on perl
socket(TSOCK, PF_UNIX, SOCK_STREAM,0); connect(TSOCK, sockaddr_un("$conf{quota_socket}")); if ($? != 0) { #error here } #After connect on socket, dovecot returns "+" or "-". Just a simple
check for data. if (defined(my $answer = <TSOCK>)) {
print TSOCK "VERSION\tdoveadm-server\t1\t0\n"; print TSOCK "PLAIN\t$conf{'doveadm_password'}\n"; TSOCK->flush; #'+' here $answer=<TSOCK>; print TSOCK "\t$local_part\@$domain\tquota get\n"; TSOCK->flush; my $quota_data = <TSOCK>; #"+" if everything is OK $answer = <TSOCK>; close TSOCK;
}
Don't forget to set doveadm_password= in dovecot config(clearttext) and you must encode password in base64 for using in a script (after PLAIN command).
PS dovecot version 2.1.15 here.
Hi,
Thank You for example but I still don't know what I doing wrong.
I set that in master.cf
service doveadm { unix_listener doveadm-server { mode = 0666 } } doveadm_password=foobar
My script now look like that:
$DOVEADM_PASS = base64_encode('foobar'); $sock = stream_socket_client('unix:///var/run/dovecot/doveadm-server', $errno, $errstr); echo fread($sock, 4096)."\n"; fwrite($sock, "VERSION\tdoveadm-server\t1\t0\n"); fwrite($sock, "PLAIN\t$DOVEADM_PASS\n"); fflush($sock); echo fread($sock, 4096)."\n"; fwrite($sock, "\tpiotr.rotter@active24.pl\tquota get\n"); fflush($sock); echo fread($sock, 4096)."\n"; fclose($sock);
I get two times "-" and that in logs
dovecot: doveadm: Error: doveadm client didn't authenticate as 'doveadm'
Please give me any tip.
W dniu 01.03.2013 23:14, Piotr Rotter pisze:
W dniu 28.02.2013 08:03, Nikita Koshikov pisze:
On Thu, Feb 28, 2013 at 1:53 AM, Piotr Rotter piotr.rotter@active24.plwrote:
Hello,
I would like to get mailbox quota by doveadm unix socket (/var/run/dovecor/doveadm-**server). I get from strace syntax of comunication:
write(9, "VERSION\t1\t0\nUSER\t1\tpiotr**.rotter@active24.pltpiotr.rotter@active24.pl
\tservice=**doveadm\n", 60) = 60 read(9, "VERSION\t1\t1\nSPID\t20805\n"**, 8192) = 23 read(9, "USER\t1\tpiotr.rotter@**active24.pl tpiotr.rotter@active24.pl \temail=piotr.**rotter@active24.pl piotr.rotter@active24.pl\tclear=** 7T33z456\thome=/vm/08/A/active**24.pl/piotr.rotter/\tuid=502\** tgid=502\tquota_rule=*:**storage=2097152000B\tquota_** rule2=*:messages=50000\nhttp://active24.pl/piotr.rotter/%5Ctuid=502%5Ctgid=502%5Ctquota_rule=*:stora...",
- = 196
and I wrote super simple client in php:
<?php $sock = stream_socket_client('unix:///**var/run/dovecot/doveadm-**server', $errno, $errstr); fwrite($sock, "VERSION\t1\t0\nUSER\t1\tpiotr**.rotter@active24.pl<tpiotr.rotter@active24.pl> \tservice=**doveadm\n"); echo fread($sock, 4096)."\n"; echo fread($sock, 4096)."\n"; fclose($sock); ?>
But i get only "+" sign and line in errorlog as below:
2013-02-28T00:39:56.377437+01:**00 kurier9 dovecot: doveadm: Error: doveadm client not compatible with this server (mixed old and new binaries?)
I would be very grateful for your help with this problem, what I doing wrong.
My current dovecot version is 2.1.13
Here is my example on perl
socket(TSOCK, PF_UNIX, SOCK_STREAM,0); connect(TSOCK, sockaddr_un("$conf{quota_socket}")); if ($? != 0) { #error here } #After connect on socket, dovecot returns "+" or "-". Just a
simple check for data. if (defined(my $answer = <TSOCK>)) {
print TSOCK "VERSION\tdoveadm-server\t1\t0\n"; print TSOCK "PLAIN\t$conf{'doveadm_password'}\n"; TSOCK->flush; #'+' here $answer=<TSOCK>; print TSOCK "\t$local_part\@$domain\tquota get\n"; TSOCK->flush; my $quota_data = <TSOCK>; #"+" if everything is OK $answer = <TSOCK>; close TSOCK;
}
Don't forget to set doveadm_password= in dovecot config(clearttext) and you must encode password in base64 for using in a script (after PLAIN command).
PS dovecot version 2.1.15 here.
Hi,
Thank You for example but I still don't know what I doing wrong.
I set that in master.cf
service doveadm { unix_listener doveadm-server { mode = 0666 } } doveadm_password=foobar
My script now look like that:
$DOVEADM_PASS = base64_encode('foobar'); $sock = stream_socket_client('unix:///var/run/dovecot/doveadm-server', $errno, $errstr); echo fread($sock, 4096)."\n"; fwrite($sock, "VERSION\tdoveadm-server\t1\t0\n"); fwrite($sock, "PLAIN\t$DOVEADM_PASS\n"); fflush($sock); echo fread($sock, 4096)."\n"; fwrite($sock, "\tpiotr.rotter@active24.pl\tquota get\n"); fflush($sock); echo fread($sock, 4096)."\n"; fclose($sock);
I get two times "-" and that in logs
dovecot: doveadm: Error: doveadm client didn't authenticate as 'doveadm'
Please give me any tip.
Hi,
I solve this, I found this code
266 if (size < 10 || data[0] != '\0' || 267 memcmp(data+1, "doveadm", 7) != 0 || data[8] != '\0') { 268 i_error("doveadm client didn't authenticate as 'doveadm'"); 269 return -1; 270 }
This mean that I don't understood that PLAIN is PLAIN and nothing else.
That is solution: $DOVEADM_PASS = base64_encode("\0doveadm\0foobar");
Thank You for help again.
On 2013-02-27 6:53 PM, Piotr Rotter piotr.rotter@active24.pl wrote:
2013-02-28T00:39:56.377437+01:00 kurier9 dovecot: doveadm: Error: doveadm client not compatible with this server (mixed old and new binaries?)
Are you sure you don't have more than one version of dovecot on this system?
doveconf -n output?
--
Best regards,
*/Charles/*
W dniu 28.02.2013 12:15, Charles Marcus pisze:
On 2013-02-27 6:53 PM, Piotr Rotter piotr.rotter@active24.pl wrote:
2013-02-28T00:39:56.377437+01:00 kurier9 dovecot: doveadm: Error: doveadm client not compatible with this server (mixed old and new binaries?)
Are you sure you don't have more than one version of dovecot on this system?
doveconf -n output?
I don't think so:
# doveconf -n # 2.1.13: /etc/dovecot/dovecot.conf # OS: Linux 3.7.1-hardened-r2 x86_64 Gentoo Base System release 2.1 auth_mechanisms = plain login digest-md5 cram-md5 ntlm apop auth_verbose = yes default_client_limit = 10000 default_process_limit = 1000 default_vsz_limit = 512 M deliver_log_format = from=%f, msgid=%m, psize=%p: %$ disable_plaintext_auth = no dotlock_use_excl = no lda_mailbox_autocreate = yes lda_mailbox_autosubscribe = yes login_greeting = Active24 Sp. z o.o. mail_access_groups = vmail mail_fsync = always mail_gid = 502 mail_location = maildir:~/ mail_nfs_index = yes mail_nfs_storage = yes mail_plugins = mail_log notify quota mail_uid = 502 mmap_disable = yes passdb { args = /etc/dovecot/dovecot-sql.conf.ext driver = sql } plugin { autocreate = Trash autocreate2 = Spam autocreate3 = Sent autocreate4 = Drafts autosubscribe = Trash autosubscribe2 = Spam autosubscribe3 = Sent autosubscribe4 = Drafts mail_log_events = delete undelete expunge copy mailbox_delete mailbox_rename mail_log_fields = box msgid from size quota = maildir
quota2 = maildir:user quota
quota_rule = *:storage=10GB
quota_rule2 = *:messages=10000
quota_rule3 = Trash:storage=+10M
quota_rule4 = Trash:messages=+100
sieve_global_path = /etc/dovecot/sieve/default.sieve
}
sendmail_path = /usr/sbin/postfix
service auth {
client_limit = 10000
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0666
user = postfix
}
unix_listener auth-userdb {
group = vmail
mode = 0600
user = vmail
}
}
service imap-login {
process_limit = 1000
process_min_avail = 5
} service imap { process_limit = 1024 } service lmtp { inet_listener lmtp { address = 0.0.0.0 port = 24 } process_limit = 100 process_min_avail = 5 user = vmail } service pop3-login { process_limit = 1000 process_min_avail = 5 } service pop3 { process_limit = 1024 } ssl_ca =
On 2013-02-28 6:22 AM, Piotr Rotter piotr.rotter@active24.pl wrote:
W dniu 28.02.2013 12:15, Charles Marcus pisze:
On 2013-02-27 6:53 PM, Piotr Rotter piotr.rotter@active24.pl wrote:
2013-02-28T00:39:56.377437+01:00 kurier9 dovecot: doveadm: Error: doveadm client not compatible with this server (mixed old and new binaries?)
Are you sure you don't have more than one version of dovecot on this system?
I don't think so:
The error above suggests otherwise...
--
Best regards,
*/Charles/*
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Thu, 28 Feb 2013, Charles Marcus wrote:
On 2013-02-28 6:22 AM, Piotr Rotter piotr.rotter@active24.pl wrote:
W dniu 28.02.2013 12:15, Charles Marcus pisze:
On 2013-02-27 6:53 PM, Piotr Rotter piotr.rotter@active24.pl wrote:
2013-02-28T00:39:56.377437+01:00 kurier9 dovecot: doveadm: Error: doveadm client not compatible with this server (mixed old and new binaries?)
Are you sure you don't have more than one version of dovecot on this system?
I don't think so:
The error above suggests otherwise...
- From my own experience with the Dovecot admin socket I can say: the error is pretty generic. When you do not use the correct syntax, that error is logged.
E.g.:
correct: VERSION\tdoveadm-server\t1\t0\n VERSION\tdoveadm-server\t1\n
you get above error with: VERSION\tdoveadm-server\t1 0\n VERSION\tdoveadmserver\t1\t0\n
It is worth checking still, if one has another server running on the host, but the error does not mean that the server has detected an old protocol version or something like that.
Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux)
iQEVAwUBUS9Xs13r2wJMiz2NAQLsYgf9H2E2IvV+HbeYUsa/AJOvCrtp9lz8IN+w apqgKAG0JezuBA7m9skZ7BIKmAJhwc3ljsrUeLI4scO+hU2bJjn10cjbAYQWLw6g grJIex59j1UCL2qbQly3E4LxFCRZvhzkslDzohE4aOMkMf+E/WBWyaaG3hH4AmTQ 40JJ1iu/z6qG6abGVg8TMFTrA/bnzgh1y9P/xaeVA39UZZUE5EDSsxYJYTJT9Y3V XHkuAeyl9rgr0g7yZZ+lmj13kIFiq1lQQwISydBp6rqJ7WSgR3wNONK3QD94ZNOx T5aEf7y3FxWv2T+amEo9QnXxm6wWQnNVwLxrVlNBlwrBO5atMJBeow== =wERt -----END PGP SIGNATURE-----
participants (4)
-
Charles Marcus
-
Nikita Koshikov
-
Piotr Rotter
-
Steffen Kaiser