Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Ugly hack at noon

I just spent the af­ter­noon at a clien­t's hack­ing qmail+­couri­er to work stor­ing mail on a NT serv­er.

Why? Well, mi­gra­tion is­sues, from NT to Lin­ux.

And what had to be hacked? Lot­s.

  • You can't chmod over SMB

  • You can't link() over SMB (y­ou can un­link(), though), so in or­der to have atom­­ic mes­sage moves from Maildir/tmp to Maildir/new and what­ev­er, re­­name()

  • Good thing this was a sin­­gle-UID qmail sys­tem: you can't chown ei­ther ;-)

  • Couri­er's meta­­da­­ta is cre­at­ed on Maildir/tmp and moved: same prob­lem as above

  • Cranky per­mis­­sion checks fixed via uid,gid,f­­mask mount op­­tion­s.

  • It had to work with a canned we­b­­mail thing, which ex­pects all mail to be in one fold­er on disk, so Maildir/cur and Maildir/new have to be sym­links to a sin­­gle fold­er.

  • Since you can't have sym­links on SM­B, Maildir is lo­­cal, but sub­­dirs of it are sym­links to the SM­B-­­moun­t­ed thing

  • Then couri­er's pop does­n't work be­­cause you can't re­­name from Maildir/tmp (over SM­B) to maildir/­­couri­er­pop­what­ev­er (lo­­cal), so hack couri­er to use mk­stemp or what­ev­er

  • Then couri­er got each mail twice. Looks like it sees two UIDLs for the same file, de­pend­ing on whether it's read or not (my guess: be­­cause we are mix­ing Maildir/cur and Maildir/new on one fold­er). Make couri­er use al­ter­­na­­tive UIDL for­­mat and it work­s.

And so on. About two hours, and I am pret­ty sure noone has ev­er done some­thing like this be­fore. On the oth­er hand, when noone has done some­thing like this be­fore, they usu­al­ly had a very good rea­son!


Contents © 2000-2024 Roberto Alsina