[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: qouta handling

Hello Jens,

The quota mechanism is explained in the section about 'database layout'.
Each time a mail should be locally delivered, qmail-getpw connects to the 
database and requests informations such as uid,gid,homedir and quota.
If the quota aren't set to '0', qmail-local will check the diskspace 
currently used by that account. If it exceeds the limit set it in the database,
it will return a soft error. If the current amount is still beneath the
limit, qmail-local will deliver the mail - even if the size of the resulting
mailbox exceeds the allowed size. Of course the following messages won't be
delivered until there's more space available.

Considering this mechanism, it's clear qmail-smptd cannot know whether
the quota are exceeded or not: it runs as user 'qmaild' and doesn't have
permission to check the homedir of a specific user. So qmail-smptd will
always accept the mail and the quota-check only happens when trying to
deliver the mail.

If you want to bounce the mail immediately, you can very easily modify
qmail-local to return a hard error instead of the soft error. However
qmail-smtpd will still accept the mail.

If one wants qmail-smptd to reject the mail immediately, one has to invent
a mechanism to check the currently used diskspace without accessing the
directory. The most obvious choice is to modify the database-design with
a field 'currently_used': qmail-smtpd and qmail-getpw both have access to
the database. But after delivering a mail, qmail-local has to update the
database again. As qmail-local runs with the userid of the actual mail-account,
everybody would need read-access to the sqlserver-file, which is _bad_.
I'm very interested in a good solution for this problem. 
Besides patching qmail, one would also have to patch the pop/imap-daemons
to correctly update the database too. Oh, let's hope you don't have 
shell-users on the system, since their software needs updating too :(

You're not the first person asking me this question and probably won't be
the last. But i don't know any good solution to implement this feature.
All suggestions are really welcome !


On Sat, Nov 23, 2002 at 08:03:05PM +0100, Jens Franke wrote:
> Hi,
> how did quota work with qmail-sql ?
> We noticed that qmail-smtpd doesn´t check the quota. 
> According to the sources qmail-local checks for quota.
> But only the maillog shows up a message:
> [...] delivery 18: deferral: Quota_exceeded/
> And the mail is hold in the queue until some spaces is freed
> in the users home.
> There is no other way to discover an Quota_exceeded than scanning the
> logs. Why doesn´t qmail-smtpd checks the qouta and give an error at
> smtp Process ? 
> bye,
> Jens