[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mailbox path formatting feature

On Thu, Sep 09, 1999 at 01:34:46PM +0400, Eugene Crosser wrote:
> Matti and guys,
> what do you think about the following feature.  If you specify a
> special new variable in zmailer.conf, it overrides MAILBOX variable
> and allows to specify the format of the path to the user's mailbox,
> that may include userid, homedir, PJW hash, domain etc.  Like this:

	How about, if "MAILBOX" variable has %-char in it, it
	will be interpreted in this manner.

	Because the PJW hash is not very good (non-uniform),
	I would add CRC32 hash there too.
	( I will separate the  crc32()  into separate routine, watch cvs.. )

	Also, some people are asking for qmail's "maildir",
	this could do that too, could it not ?

	For quite a while I have pondered about having some


	file at which people could specify local processing rules,
	e.g. if they want the incoming email stored somehow
	specially, or ran thru e.g. procmail at reception, or ...
	A snafu is that we already have procmail, and repeating
	it all within 'mailbox' won't be very productive.
	( But certain usefullness could be achieved from telling
	  that "although generally email is coming thru procmail,
	  I want unfiltered feed into maildir!" without having to
	  use some piped program thru  .forward  file ... )

	... which reminds me, "pine" reads configuration files:
	That is, first gives global defaults, second is what user
	can tune, and third enforces (sets/clears) some global values.

> # int fmtmbox(char *buf, int size, const char *format,
> #             const char *address, const struct passwd *pwd);
> #
> # format specifiers:
> #
> # %% - '%' alone
> # %u - userid
> # %U - long user name (userid if not supported)
> # %d - first element of domain name
> # %D - full domain name
> # %x - one-character derivate of PJW hash of userid
> # %X - two-character derivate of PJW hash of userid

	Hmm... No.    %x/%x/  should be equivalent to  %X
	Then we have "%X" free for other uses. (e.g. CRC32)

	Algorithm something like:

	/* That has is hardly ever zero, thus... */
	int hash = 0;

	for (;*fmt;++fmt) {
	  switch (*fmt) {
		if (!hash) hash = crc32(username);
		if (!hash) hash = pjwhash32(username);
		c = 'A' + hash % 26;
		hash /= 26;
	  *out++ = c;

	You get the idea :)
	(Only one hash can be calculated per path.)

> # %h - userid's home directory
> # %d - least number guaranteening unique filename (for MH style boxes)
> # %D - the same padded by leading zeroes to fixed length
> # %(any other character) - substitute with "__" (two underscores)
> #
> # Examples:
> # "/var/mail/%u"               - standard mail directory
> # "/var/mail/%X/%u             - hashed directory
> # "%h/Mail/INBOX"              - mailbox in user's home
> # "/var/virtual/%D/mail/%X/%u" - hashed spool with virtual domain
> I think that I could work out such a thing...
> Eugene

/Matti Aarnio	<mea@nic.funet.fi>