On Thu, Feb 28, 2013 at 1:53 AM, Piotr Rotter <[email protected]>wrote:
> 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**[email protected]<[email protected]> > \tservice=**doveadm\n", 60) = 60 > read(9, "VERSION\t1\t1\nSPID\t20805\n"**, 8192) = 23 > read(9, "USER\t1\tpiotr.rotter@**active24.pl <[email protected]> > \temail=piotr.**[email protected] <[email protected]>\tclear=** > 7T33z456\thome=/vm/08/A/active**24.pl/piotr.rotter/\tuid=502\** > tgid=502\tquota_rule=*:**storage=2097152000B\tquota_** > rule2=*:messages=50000\n<http://active24.pl/piotr.rotter/%5Ctuid=502%5Ctgid=502%5Ctquota_rule=*:storage=2097152000B%5Ctquota_rule2=*:messages=50000%5Cn>", > 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**[email protected]<[email protected]> > \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.
