Discussion:
[Courier-imap] Quota problem with IMP, how to test
Marc Berthold
21 years ago
Permalink
Hi,
I'm fighting with IMP to show the maildir quota.

Actualy I don't know if my IMP setup is crap or if courier-imap is not
working properly.
The imap server get the data from a mysql database.

As anybody a good idea how I can test the quota system of the
courier-imap server ?

Kind regards,
Marc
--
#include <standard.disclaimer>
Berthold Marc, Rolle, Switzerland

// Computers are only interesting when they go wrong,
// otherwise it's just like watching television !!!
Development - multi.art.studio
21 years ago
Permalink
hi,

i never used quota, but maybe you simply create a testaccount
set quota to 1M and send a big mail to it, after receiving more than 1MB
of emails,
emails will bounce and the sender is informed about the 'over-quota' of
the user.

have luck,

volker
Post by Marc Berthold
Hi,
I'm fighting with IMP to show the maildir quota.
Actualy I don't know if my IMP setup is crap or if courier-imap is not
working properly.
The imap server get the data from a mysql database.
As anybody a good idea how I can test the quota system of the
courier-imap server ?
Kind regards,
Marc
Jay Lee
21 years ago
Permalink
First we need to determine whether Courier or IMP's config is the problem:

telnet imap.server.com 143

Server should say something similar to:

* OK [CAPABILITY IMAP4rev1 NAMESPACE CHILDREN IDLE QUOTA SORT
THREAD=ORDEREDSUBJECT THREAD=REFERENCES UIDPLUS STARTTLS] Courier-IMAP
ready. Copyright 1998-2003 Double Precision, Inc. See COPYING for
distribution information.

The QUOTA capability is important as it's telling the client that the
server supports quotas, if it's not there then you need to tweak your
Courier config.

Now type:

a01 login quotauser userpassword

where quotauser and userpassword are the username/pass of a user with a
set quota.

select INBOX
getquota ROOT

if this doesn't work the problem is with your IMAP config. You didn't
include any details on how your doing quota's though, are you using
Filesystem quota's or maildir style quota's? If the telnet session works
then the problem is with IMP.

Jay

~~~~~~~~~~~~~~~~~~~~~~~~~
Jay Lee
Network / Systems Administrator
Information Technology Dept.
Philadelphia Biblical University
Langhorne, PA
~~~~~~~~~~~~~~~~~~~~~~~~~~
Post by Marc Berthold
Hi,
I'm fighting with IMP to show the maildir quota.
Actualy I don't know if my IMP setup is crap or if courier-imap is not
working properly.
The imap server get the data from a mysql database.
As anybody a good idea how I can test the quota system of the
courier-imap server ?
Kind regards,
Marc
Marc Berthold
21 years ago
Permalink
Hi Jay,

Your answer is exactly what I was looking for ! :-) Thank you very much
!!! :-D

However something looks brocken. I tried you method and I get the following:

nadine:~# telnet 10.0.0.4 143
Trying 10.0.0.4...
Connected to 10.0.0.4.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE
THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE] Courier-IMAP
ready. Copyright 1998-2003 Double Precision, Inc. See COPYING for
distribution information.
a01 login user password
a01 OK LOGIN Ok.
select INBOX
select NO Error in IMAP command received by server.
a01 select INBOX
* FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)
* OK [PERMANENTFLAGS (\Draft \Answered \Flagged \Deleted \Seen)] Limited
* 6 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1078677529] Ok
a01 OK [READ-WRITE] Ok
a01 getquota ROOT
* QUOTA "ROOT"
a01 OK GETQUOTA Ok.

The QUOTA in the hello banner is there, how ever this banner is a static
string from the config file.
But at least it give me a bit of hope ! ;-)

It's look like IMAP accecpt the command getquota but never send
something back !?
Is there a problem with the IMAP command or is courier-IMAP brocken ?

BTW: I use a debian Sarge system for my setup.

Kind regards,
Marc
...
Jay Lee
21 years ago
Permalink
It sounds like Courier IMAP is working just fine but as far as it can tell
there is no quota set on the mailbox. This may be because the quota was
not set properly or the IMAP process may not have read-write access rights
to the maildirsize file to determine quota settings. In the latter case,
Courier will simply assume there is no quota. Go into a user's
$HOME/Maildir directory and do a "ls -l". Mine looks like this:

total 27
drwx------ 2 vmail vmail 72 Mar 10 08:57 courierimapkeywords
-rw-r--r-- 1 vmail vmail 926 Mar 3 21:30 courierimapsubscribed
-rw-r--r-- 1 vmail vmail 1064 Mar 10 08:57 courierimapuiddb
drwx------ 2 vmail vmail 1304 Mar 10 08:57 cur
-rw-r----- 1 vmail vmail 5012 Mar 10 08:57 maildirsize
drwx------ 2 vmail vmail 48 Mar 10 04:14 new
-rw------- 1 vmail vmail 4 Jan 11 19:51 sqwebmail-curcnt
-rw------- 1 vmail vmail 1 Jan 11 20:06 sqwebmail-timestamp
drwx------ 2 vmail vmail 48 Mar 10 09:04 tmp

Notice the maildirsize file is owned by vmail as are other files. If your
file exists but is owned by root or some other user, there's your problem.
All of my Maildirs are owned by vmail because we use LDAP for virtual
user's rather than creating real system accounts for each user. In your
case though, you should determine who should own the files then do a:

chown -R vmail.vmail $HOME/Maildir/maildirsize
chmod 0640 $HOME/Maildir/maildirsize

Somebody correct me if those permissions aren't secure but that should work.

Jay

~~~~~~~~~~~~~~~~~~~~~~~~~
Jay Lee
Network / Systems Administrator
Information Technology Dept.
Philadelphia Biblical University
Langhorne, PA
~~~~~~~~~~~~~~~~~~~~~~~~~~
Tony Earnshaw
21 years ago
Permalink
ons, 10.03.2004 kl. 15.13 skrev Jay Lee:

[...]
Post by Jay Lee
Notice the maildirsize file is owned by vmail as are other files. If your
file exists but is owned by root or some other user, there's your problem.
All of my Maildirs are owned by vmail because we use LDAP for virtual
user's rather than creating real system accounts for each user. In your
chown -R vmail.vmail $HOME/Maildir/maildirsize
chmod 0640 $HOME/Maildir/maildirsize
Jay - and any others,

I can get my head around the vmail:vmail stuff and implement it (thanks
Johan Vriesman and others).

What I can't get my head round, is: If a virtual account user,
***@billy.demon.nl, say, wants access to his mail, then normally, if
his mail were in his ~/Maildir, he'd be the owner and be
authenticated/authorized by his password. If all his (and every other
virtual user's) mail is owned by vmail:vmail, how does he authorize? How
does he get access to his mail? He can't give the same password as all
other users, since he'd then have access to their mail too.

Sorry to be dense :)

--Tonni
--
mail: billy - at - billy.demon.nl
http://www.billy.demon.nl


==================================================
This is a disclaimer. I disclaim everything, no
skin of my nose, oh no.
==================================================
Tony Earnshaw
21 years ago
Permalink
Post by Tony Earnshaw
What I can't get my head round, is: If a virtual account user,
his mail were in his ~/Maildir, he'd be the owner and be
authenticated/authorized by his password. If all his (and every other
virtual user's) mail is owned by vmail:vmail, how does he authorize? How
does he get access to his mail? He can't give the same password as all
other users, since he'd then have access to their mail too.
Solved off list by Jay; thanks a lot, Jay :)

--Tonni
--
mail: billy - at - billy.demon.nl
http://www.billy.demon.nl
Marc Berthold
21 years ago
Permalink
Hi Jay,
I did some more test with your remarques !

Basicly my setup schould take the quota from a mysql database.

I have the config file authmysqlrc with:
MYSQL_QUOTA_FIELD quota

The auth system with the DB is working fine, just not the quota ! :-/
However here is the content of authmysql:

MYSQL_SERVER 127.0.0.1
MYSQL_USERNAME vmail
MYSQL_PASSWORD password
MYSQL_PORT 0
MYSQL_OPT 0
MYSQL_DATABASE provider
MYSQL_USER_TABLE users
MYSQL_CRYPT_PWFIELD password
MYSQL_UID_FIELD uid
MYSQL_GID_FIELD gid
MYSQL_LOGIN_FIELD email
MYSQL_HOME_FIELD homedir
MYSQL_MAILDIR_FIELD maildir
MYSQL_QUOTA_FIELD quota


I tried it by creating a file call maildirsize wich content is:
nadine:/home/vmail/***@gorfou.ch# cat maildirsize
1000000
nadine:/home/vmail/***@gorfou.ch#

But I got the following result:
nadine:/home/vmail/***@gorfou.ch# telnet localhost 143
Trying 127.0.0.1...
Connected to nadine.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE
THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE] Courier-IMAP
ready. Copyright 1998-2003 Double Precision, Inc. See COPYING for
distribution information.
a01 login ***@gorfou.ch test
a01 OK LOGIN Ok.
a01 select INBOX
* FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)
* OK [PERMANENTFLAGS (\Draft \Answered \Flagged \Deleted \Seen)] Limited
* 6 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1078677529] Ok
a01 OK [READ-WRITE] Ok
a01 getquota ROOT
* QUOTA "ROOT"
a01 OK GETQUOTA Ok.
a01 logout
* BYE Courier-IMAP server shutting down
a01 OK LOGOUT completed
Connection closed by foreign host.
nadine:/home/vmail/***@gorfou.ch#


Jay, is the content of the maildirsize file correct ?
I use the debian Sarge packages courier-imap 1.7.3-10, is there any
knowed problem with ?

Thank you very much for you help ! :-)

Kind regards
Marc
...
--
#include <standard.disclaimer>
Berthold Marc, Rolle, Switzerland

// Computers are only interesting when they go wrong,
// otherwise it's just like watching television !!!
Brian Candler
21 years ago
Permalink
Post by Marc Berthold
Basicly my setup schould take the quota from a mysql database.
MYSQL_QUOTA_FIELD quota
...
Post by Marc Berthold
1000000
That is invalid syntax for the quota string. Read
maildir/README.maildirquota.html for the correct syntax.

However, in any case, quota enforcement won't work properly unless your
*delivery* agent supports it. Personally I use 'deliverquota' as local
delivery agent (invoked from exim). You pass the quota on the command line,
and the maildirsize file is created automatically if it does not exist. You
can also use 'maildrop'. Or you can use any MTA which has built-in support
for the maildirsize file.

$ openssl s_client -connect x.x.x.x:993
...
* OK [CAPABILITY IMAP4rev1 CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN] Courier-IMAP ready.
a login xxxxxxxx yyyyyyyy
a OK LOGIN Ok.
a examine inbox
* FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)
* OK [PERMANENTFLAGS ()] No permanent flags permitted
* 1 EXISTS
* 1 RECENT
* OK [UIDVALIDITY 1079088006] Ok
a OK [READ-ONLY] Ok
a getquota "ROOT"
* QUOTA "ROOT" (STORAGE 36 97657)
a OK GETQUOTA Ok.

Brian.
Development - multi.art.studio
21 years ago
Permalink
Hello all,

i also tried to include quota with courier2 and i tested with telnet.

it shows:
[***@tomcat Courier-2.2.1]# telnet mail.MYSERVER 143
Trying 217.175.253.115...
Connected to mail.MYSERVER
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 QUOTA CHILDREN NAMESPACE
THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT AUTH=CRAM-MD5
AUTH=CRAM-SHA1 STARTTLS] Courier-IMAP ready. Copyright 1998-2003 Double
Precision, Inc. See COPYING for distribution information.
a01 login USER PASSWD
a01 OK LOGIN Ok.
select INBOX
select NO Error in IMAP command received by server.
getquota ROOT
getquota NO Error in IMAP command received by server.
select inbox
select NO Error in IMAP command received by server.
select Inbox
select NO Error in IMAP command received by server.
select .INBOX
select NO Error in IMAP command received by server.


hmmm, but select does not work, or what does NO Error mean? i seems that
this curious message tell me an error or what? sorry i didnt understand.

i use pgsql for my usertable, have a field 'quota' with value
'1000000000S,100000000C' in each row to bes sure no account i over quota.
after adding the quota capability to imapd, mozilla tells me my account
uses quota, BUT quota is not set.
so i have set a value in the quota field of the db, and also this field
is defiuned in authpgsqlrc.

i also tried creating a maildirsize file by hand.
1000000000S 100000000C
in one line
also tested with 1000000000 100000000 in one line
i also recognized that README.maildirquota from source differs to that
on the internet ;)
but none of these was a big help.
i tried to create a maildir by hand, with maildir /home/test and it
working fine, but with q-option, it hangs.....

everything is fine but quota :( imap works great with pgsql, ssl and
more, but quota always fails.

i use exim4 as smtp-server, not implemented quota yet, because i want it
in courier runnning fine first.

any help would be greatly appreciated, and sorry for my b-r-o-k-e-n english

yours sincerely,
volker
...
Brian Candler
21 years ago
Permalink
Post by Jay Lee
select INBOX
select NO Error in IMAP command received by server.
getquota ROOT
getquota NO Error in IMAP command received by server.
select inbox
select NO Error in IMAP command received by server.
select Inbox
select NO Error in IMAP command received by server.
select .INBOX
select NO Error in IMAP command received by server.
hmmm, but select does not work, or what does NO Error mean? i seems that
this curious message tell me an error or what? sorry i didnt understand.
"NO" means "could not process command".
"NO Error in IMAP command received by server." means, in this case, syntax
error - you typed a junk command.

All those commands above are junk. They are missing the tag (for example
"a001" which you gave in your LOGIN command but not any subsequent
commands).

RFC 3051 defines the IMAP protocol.
Post by Jay Lee
i use pgsql for my usertable, have a field 'quota' with value
'1000000000S,100000000C' in each row to bes sure no account i over quota.
after adding the quota capability to imapd, mozilla tells me my account
uses quota, BUT quota is not set.
Does your Maildir contain a file called 'maildirsize'?

If not, don't create it by hand. It should be created automatically when you
next copy a message into that mailbox.

However, for quotas to work, you need to configure your MTA to honour quotas
when it delivers new messages *into* the mailbox (and at that time it will
also create the 'maildirsize' file) using the Maildir++ protocol.

If your MTA supports Maildir++ natively, then configure it to find the quota
information. If not, then instead configure it to run either 'deliverquota'
(included with courier-imap) or 'maildrop' (separate package) as its local
delivery agent, passing the quota string on the command line.
Post by Jay Lee
i use exim4 as smtp-server, not implemented quota yet, because i want it
in courier runnning fine first.
Quotas aren't much use if delivering a new mail into the mailbox doesn't
update the maildirsize file, and when the mailbox is full you want incoming
mails to be bounced anyway.

So you need something like:

quota = ${if match { .... }{([0-9]+)S}{$1}{}}
quota_filecount = ${if match { .... }{([0-9]+)C}{$1}{}}

where .... is an expression which evaluates to the Maildir++ quota string
(e.g. "10000000S,10000C") for that mailbox.

Regards,

Brian.
Development - multi.art.studio
21 years ago
Permalink
Thanks!

thats what i need to know, i wasnt shure how the maildirsize-file is
created.
i will also try to read the RFC carefully an test it that way.
exim is already configurred to use maildirs, dealing with exim and
maildirquota is well documented.

now another question, i got one account working and it show me i use 0%
of 97.xxxmb, but i use at least 10mb -
i only test with imap at this time and moved some mails from there to
there to be sure a maildirsize file is created by courier-imap.
but there is no such file created at all.
if so, how would courier-imap handle this? e.g. i have one account with
about 1000 mails, and it uses ...lets say 20mb and 10 subdirectories,
does courier search all directories?
how often does courier search for filesizes in each directory? i read
the maildirquota readme, but i didnt find that part - i think this is
not courier-imap specific.

does courier update and count all mails and mailsize for each directory
i have a look into? and what if i enable quota in a maildir with a lot
of existing mails?

so much questions :)

thanks in advance.
...
Development - multi.art.studio
21 years ago
Permalink
Hello all,

quota is working just fine now, i configured exim4 like described here:
http://www.flatmtn.com/computer/Linux-Exim4.html#Exim4-6.3 (great docu)
and its creating now the maildirsize and always uses values from DB.
GREAT STUFF!
hmm, exim uses 10M as a value for 10 megabytes of maildir....., does
courier use also a value ike 10M? i think its 1024000S?
ok, i have created a second field in my table......i have to ask the
exim list.

thanks,
volker
...
Brian Candler
21 years ago
Permalink
Post by Development - multi.art.studio
http://www.flatmtn.com/computer/Linux-Exim4.html#Exim4-6.3 (great docu)
and its creating now the maildirsize and always uses values from DB.
GREAT STUFF!
hmm, exim uses 10M as a value for 10 megabytes of maildir....., does
courier use also a value ike 10M? i think its 1024000S?
(exim) 10M = (courier) 1048576S

Check in the first line of the maildirsize file that's what exim writes. Or:

(exim) 10000000 = (courier) 10000000S

But actually, once exim has delivered a mail, you do not need to set a quota
for courier-imap at all; it will pick up the existing quota from the
maildirsize file which exim has already created.

Brian.

Loading...