Skip to content

Fixed cf-execd SMTP mock and reapplied dot-stuffing - #6428

Open
larsewi wants to merge 3 commits into
cfengine:masterfrom
larsewi:mail-dot-stuffing
Open

larsewi wants to merge 3 commits into
cfengine:masterfrom
larsewi:mail-dot-stuffing

Conversation

@larsewi

@larsewi larsewi commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Reapplies #6411, which was reverted in #6427 because mail_dot_line.cf failed intermittently.

The cause was the SMTP mock used by the cf-execd tests. It checked each recv() chunk on its own for the end of DATA marker. When the stuffed dot and the rest of the line arrived in separate chunks, a chunk of exactly ".\r\n" ended DATA early. The mock now tracks the last bytes across chunks.

The mock also no longer loops forever if the connection closes before the end of DATA.

🤖 Generated with Claude Code

@larsewi

larsewi commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

@cf-bottom Jenkins please :)

@larsewi
larsewi requested a review from olehermanse October 21, 2026 08:30
{
memmove(last, last + 1, sizeof(last) - 1);
last[sizeof(last) - 1] = recvbuf[i];
done = (memcmp(last, "\r\n.\r\n", sizeof(last)) == 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT this memcmp could be done after the loop, since the marker should always appear at the end, even if split (?).

larsewi and others added 3 commits October 21, 2026 13:16
The mock checked each recv() chunk on its own for the end of DATA
marker. A chunk boundary inside the body could match it, e.g. when a
dot-stuffed line was split across two chunks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
This reverts commit dee2d4d.

The test failures were caused by the SMTP mock, fixed in the previous
commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Changelog: cf-execd now dot-stuffs mailed output lines starting with '.'
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
@cfengine cfengine deleted a comment from cf-bottom Oct 21, 2026
@cfengine cfengine deleted a comment from cf-bottom Oct 21, 2026
@cf-bottom

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants