2016-03-06 11:21 GMT+01:00 Stuart Henderson <s...@spacehopper.org>: > On 2016/03/06 09:07, ludovic coues wrote: >> 2016-03-05 22:56 GMT+01:00 Stuart Henderson <s...@spacehopper.org>: >> > >> > For OpenSMTPD I haven't tried it but I suspect you may be able to do >> > this with a virtual map using a python script via table-python (in >> > ooensmtpd-extras in ports) but there isn't much documentation for >> > this. Though actually a quick search for "opensmtpd table-python" >> > throws up https://gist.github.com/unconfigured/e72a18f3dd12f7c4fc5c >> > which looks pretty much like what you need there. >> > >> >> OpenSMTPD in base 5.8 support sqlite table which might be enough. > > The mapping would need to be something like 'foo-...@example.com' -> 'foo' > or 'foo-...@example.com' -> 'example', I don't see how to do this with the > string handling functions available in sqlite. (And in 5.9+ the sqlite > table is in opensmtpd-extras as well). >
I might be missing some corner-case but "instr" look like a good fit. sqlite > create table user (username text, uid int, gid int, home text); sqlite > insert into user values ("foo", 1000, 10, "/home/foo"); sqlite > insert into user values ("bar", 1001, 10, "/home/bar"); sqlite > select * from user where instr("foo-...@exemple.com", username) = 1; foo I assume it would work roughly the same for alias. In the end, it's a matter of personal preference, even more if support for sqlite is dropped from base. -- Cordialement, Coues Ludovic +336 148 743 42