Is 'alias exists' hook requerd for 'alias resolve' hook to work?

19 views
Skip to first unread message

eubyte

unread,
May 12, 2020, 4:52:06 PM5/12/20
to chasquid
We implemented the 'alias resolve' hook with a DB lookup, and it works as it should. The alias (al...@domain.tld) is resolved, and the hook returns the target email account (us...@domain.tld).

However, whenever we try to send an email to 'al...@domain.tld', the email bounces back with a '550 recipient unknown' error. Chasquid seems to be unaware of 'al...@domain.tld'.

The question is: do we need to also implement an 'alias exists' hook to make Chasquid recognize the alias, or is there something else we are doing wrong?

Thank you!

Alberto Bertogli

unread,
May 12, 2020, 7:33:01 PM5/12/20
to eubyte, chasquid
In that case, you need to implement both.

I thought of doing only a single hook, but some use cases work better
with two separate ones.

Thanks!
Alberto

eubyte

unread,
May 14, 2020, 10:55:25 PM5/14/20
to chasquid
Thanks Alberto!

Unfortunately, we are still unable to make the alias hooks work. Our setup is virtual users with Dovecot. Both hooks seem to work just fine from the command line: 'alias-exists' exits with 0, and 'alias-resolve' returns 'target-user@domain', but chasquid still rejects the alias with '550 recipient unknown'.

If we use text file based aliases -- everything works just fine.

Any ideas/pointers are very much appreciated.

Thank you.

Alberto Bertogli

unread,
May 15, 2020, 1:26:21 PM5/15/20
to eubyte, chasquid
Are the hooks executable (permissions +x) ?

What do the logs show? Have you enabled debug logs or looked at the
monitoring server to see what the attempts at running the hooks say?

The per-request should have entrie for the two different aliases hooks,
with details of their invocation including the stdout.

The same information also appears in the logs with -v=1.

If you don't see them there, chances are they are not in the expected
path, or they are not executable.

Thanks,
Alberto

eubyte

unread,
May 19, 2020, 12:46:40 PM5/19/20
to chasquid
Thanks for your ongoing help!

The root of the problem was that we installed chasquid from the Ubuntu repo, and the version was 0.4 or something -- the one which probably didn't even have alias hook support. We then compiled from source to get the latest, and debug vars from the monitoring server stated to show alias hook results (exists: false), but no other useful information. We still see nothing in the logs (even with -v=1 in the systemd service), except for 'rejected - local user does not exist'.

The 'alias-exists' hook is executable, sits in /etc/chasquid/hooks/, and works fine from the command line -- returns exit code of 0.

Any ideas are much appreciated.

Thank you again.

Alberto Bertogli

unread,
May 22, 2020, 9:47:37 AM5/22/20
to eubyte, chasquid
Seeing "exists:false" in the debug vars means chasquid ran the hook and
the hook exited with a code != 0 (see [1]).

So that's good.


You can debug this further by going to the monitoring server's request
traces -> Hook.Alias-Exists -> [≥0s].

The url will be something like
http://yourserver/debug/requests?fam=Hook.Alias-Exists&b=0&exp=1

There you should be able to see each run and the exit status.

The text output for this hook is it's not recorded for now. I just wrote
a patch to include it, to ease troubleshooting.
It's in the `next` branch, if you want to give it a try [2].


Remember that the hooks are run from chasquid's config directory and
with chasquid permissions. So maybe your hook works when run as you, but
not when run as chasquid's user?

I hope this helps!

Thanks,
Alberto

[1]: https://blitiri.com.ar/git/r/chasquid/b/master/t/internal/aliases/f=aliases.go.html#line-459
[2]: https://blitiri.com.ar/git/r/chasquid/c/9fe790d7c6d0b9b98c1f63651d2d8ff4eac74d0e/
Reply all
Reply to author
Forward
0 new messages