Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: add odkim.replace_header/odkim.add_header/odkim.del_header to "final" lua script for actual content change #241

Open
ell1e opened this issue Jan 26, 2025 · 3 comments

Comments

@ell1e
Copy link

ell1e commented Jan 26, 2025

It seems like header modification is only allowed before signature check in lua, and then only as a temporary operation not passed on to the target mail daemon:

Note that this only changes the content of the header field used when generating or verifying the signature; the actual delivered message is not modified.

It would be nice if odkim.replace_header(ctx, name, n, newval) and odkim.add_header(ctx, name, value) and odkim.del_header(ctx, name, n) were available in the final script, and in a way where it persists for actual delivery. I understand this is not at all the intended core use for OpenDKIM, but since it already has this great flexible Lua API this would open up the door for doing many rewriting and administrative tasks in a simple Lua script that may otherwise be relatively cumbersome to set up using different postfix submission queues. Especially if the rewrite logic is meant to be relatively complex.

I understand if this is too far out of scope. I just thought the idea would be too useful not to try to suggest it. Thanks so much for working on OpenDKIM, and sorry for taking up your time.

@futatuki
Copy link

I've not checked, but it seems PR #211 resolves your request.

@futatuki
Copy link

The code for odkim.replace_header() does not call libmilter API for changing headers, so the description

Note that this only changes the content of the header field used when generating or verifying the signature; the actual delivered message is not modified.

is for it.

On the other hand, LUA funcition odkim.add_header() calls libmilter API smfi_insheader() through the function dkimf_insheader() and odkim.del_header(ctx, name, n) calls libmilter API smfi_chgheader() through the function dkimf_chgheader(). Both of "add_header" and "del_header" is in dkimf_lua_lib_final[], so I think they can be used in a final script (although for del_header(), it might need PR #211, depends on your configuration).

@ell1e
Copy link
Author

ell1e commented Jan 26, 2025

That would be super exciting if this could at some point work! OpenDKIM does some really cool stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants