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
qmail-remote: add infrastructure for EHLO parsing #173
base: main
Are you sure you want to change the base?
Conversation
d34b10e
to
b4419ec
Compare
Would be nice if someone finds out why it doesn't use the %.o rule in the subdirectory. |
725dfa2
to
5e1847e
Compare
5e1847e
to
192934b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This opens the discussion (along with the EHLO generator branch) for how to extend qmail:
- through tables that patches fill to add hooks
- through inline functions() calls in the source to indicate the extension writer where to place its hooks.
(1.) has the advantage of being explicit.
(2.) looks more like DJB very-static programming structures with few indirections
I prefer 1.
Maybe it can be simplified (for us, but more to write on extension writer part) by letting each callback parse the entire 250-CAPABILITY STRING
?
[EDIT: changes requested are for checking the overflow]
* @brief parse the EHLO replies | ||
* @param smtptext the reply to parse | ||
* @param callbacks the list of callbacks | ||
* @param count number of entries in callbacks | ||
* @return mask of the matched callbacks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not remember these style of specifications, is the plan to add more as we touch to the source?
It would then help to have a hint about the syntax on the Mailing list or elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doxygen ;)
* callback in case a space character follows name in the EHLO response | ||
* The function is given the current extension line without the leading 250- | ||
* and the length of the remainder, not including the trailing newline. This | ||
* includes the name part of the line so one could reuse the same callback | ||
* for multiple extensions. | ||
* | ||
* The callback shall return 0 if the line was ignored, or 1 if it was | ||
* accepted. | ||
* | ||
* In case the callback is NULL the extension is automatically accepted if | ||
* the name is matched and either followed by a space or newline. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theses documentations will become very useful for writing patch extensions. There could be a EXTENDING file that point at these various locations that help extending it.
tcase_add_test(tc, test_ehlo_noparams); | ||
tcase_add_test(tc, test_ehlo_nodupes); | ||
tcase_add_test(tc, test_ehlo_params); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe adding a test for a 3-byte thingy.s
to check whether there is overflow? (see above)
How does the extension writer knows what to do with the bitmask returned by ehlo_parse()? It works for static arrays where extension writers can [EDIT: For checking which capability the remote has from an extension: maybe a
Then matching the extension and the callback entry is done, and this does not require cooperation between the various patches thanks to declarations of |
thingy.len = strlen(thingy.s); | ||
|
||
const struct smtpext callbacks[] = { | ||
bad_call_entry, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not know the compiler could handle inlining a static struct into an array. I thought it was only possible with pointers. This is convenient.
5145e99
to
33dc39a
Compare
Are there so many EHLO-capability-implementing extensions for qmail-remote out there? The TLS patch, maybe the AUTH patch... what else exists that I should be aware of? |
I immediately remember SIZE and SMTPUTF8. |
Thought of SMTPUTF8 right after posting, as one does. Managed to not have SIZE occur to me despite having re-read that RFC today. Perhaps unsurprisingly, I can’t imagine there being too many other popular qmail-remote patches. But maybe I’m not wrong this time :-p I don’t dislike this code, I’m just not sure it’s worth its cost. Are we hoping patch maintainers for SMTPUTF8, SIZE, STARTTLS, and AUTH will (1) notice and appreciate that notqmail is alive, (2) care to update their patches, (3) want to do so in a way that limits their applicability? Or are we thinking to take advantage of our branches for popular patches rebased onto notqmail and do our own publishing (and maintenance) of these affected patches? I suspect the changes in this PR don’t really pay off for us unless/until all four patches (and any other important ones we might be forgetting) have been adjusted to this new API. And it seems very unlikely to me that any of the upstream patch maintainers will want to, even if we help them. I’m not eager to deal with hand-rebasing more patches than I’ve already been doing for pkgsrc. I imagine this PR is motivated in part by you doing the same for Gentoo. Are we in agreement that all four of these bits of functionality (SMTPUTF8, SIZE, STARTTLS, AUTH) should land in the default install at some point, in some way? If you’re thinking not (for any or all), I’m open to hearing reasons why not, and then I might see more value here. But if yes, then I need to get my thoughts about refactoring |
I have written a patch that adds SIZE support long time ago and can open a PR for that so we would get that for free as a starting point. But you are right, most motivation is that patches in Gentoo collide heavily because every one of them has to create another version of EHLO parsing. |
Okay, I've tried to show what I'm thinking about for qmail-remote. Does that look like a fruitful direction to you? |
33dc39a
to
8674996
Compare
Implementing extensions for qmail-remote often requires the usage of EHLO and checking if the server supports the extension. Every patch therefore usually comes with it's own version of EHLO parsing. Add yet another one that the patches can easily hook into. For the moment it will just send mails using ESMTP instead of SMTP for basically all cases, but not use any of the new information.
8674996
to
6897896
Compare
Just a datapoint: when combining TLS and AUTH patches the custom EHLO code that both introduce collides also. So we only make things collide right from the start, not only when combining patches. But hopefully things get easier afterwards. If we could convince the upstreams to just include our EHLO patches at the start of their next version this would work with both old and new versions easily… (just dreaming). |
State of the patches for this, since we talk about it... [EDIT: as well as master: |
If Since that didn't happen, various If we change the status quo while those patches are still generally necessary, we're taking on some risk. The best-case scenario, for us, would be that all the patch maintainers release updated patches targeting notqmail 1.09 on the same day we ship it. This gambles that they're all actively maintaining their patches, they're all convinced that notqmail is the future, and they're all available to coordinate with us in a timely fashion. The worst-case scenario would be that they're inactive, unconvinced, and/or too busy. We'd be forcing ourselves to issue rebased patches and (probably, unless upstreams change their minds) maintain them for as long as they're still generally necessary. We'd be forcing our source-based users with custom patches to understand why this notqmail update is trickier than usual and why they can trust our versions of these patches. The worst-case scenario seems much more likely, which is why my spidey sense says we should do deeper structural work on I'm willing to be convinced merging this sooner won't cost us so much and will bring enough benefits to be worth the churn. I'd like to understand our plan for managing it. |
The day we start merging SMTPUTF8 or SIZE extensions we will be breaking all of those patches anyway. We should be doing this in a way that avoids breaking them again. |
Hit a key by mistake, not even sure which one |
I'm guessing we agree in principle about trying to minimize the total area under the pain curve (accounting for us as developers, us as packagers, and source-based users with patches) as we move incrementally from our current Let me propose a concrete sequence (you'll recognize it from Designs), and you can point at the steps or orderings you disagree with, and/or share the sequence you're thinking of.
We can merge to Pros:
Cons:
|
So now we end up having 3 copys. Or we have a new source file that these 3 binaries use, which will break just every patch to qmail-remote. |
Implementing extensions for qmail-remote often requires the usage of EHLO and checking if the server supports the extension. Every patch therefore usually comes with it's own version of EHLO parsing. Add yet another one that the patches can easily hook into. For the moment it will just send mails using ESMTP instead of SMTP for basically all cases, but not use any of the new information.