• src/sbbs3/mailsrvr.cpp

    From Rob Swindell (on Windows@VERT to Git commit to main/sbbs/m on Mon Oct 26 00:05:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/dd868cf96f01d669158e480b
    Modified Files:
    src/sbbs3/mailsrvr.cpp
    Log Message:
    Mail server: keep the mailproc script's callback struct alive with its context

    Fixes a crash in sbbs.dll (remove_js_socket_event) when an SMTP client
    thread ends.

    b43e1c8256 (2009-01-14) made js_mailproc() reuse one JS runtime, context
    and global object per SMTP client thread, created on the first mailproc
    and destroyed only when the thread ends, but left its js_callback_t as a
    local of js_mailproc(). The "js" object and the client.socket Socket
    object created in that persistent global recorded a pointer to the local,
    which was gone as soon as the first js_mailproc() call returned.

    Nothing followed that stale pointer after the call until 85e04a4262 (2026-09-30) made every Socket object remember its script's callback
    struct at creation and consult it when closed. From then on, destroying
    the context at thread end finalized client.socket, do_js_close() walked
    the event list of a js_callback_t that was a dead stack frame, and the
    mail server crashed with an access violation.

    Move the js_callback_t to smtp_client_thread(), beside the runtime,
    context and global, and pass it to js_mailproc(). It is still zeroed and
    given the logger on each invocation, as before.

    Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
  • From Rob Swindell (on Debian L@VERT to Git commit to main/sbbs/m on Wed Nov 11 13:04:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/59bb834db75f09c19a9bfd0c
    Modified Files:
    src/sbbs3/mailsrvr.cpp
    Log Message:
    mailsrvr: don't treat a failed user re-read as an unauthenticated client

    When an authenticated SMTP client sent to an external address, the relay
    check re-read the user's record with getuserdat() and ignored the result. getuserdat() zeroes user->number on failure, so a transient error such as
    a user record lock timeout made the session unauthenticated: the RCPT was refused as an "ILLEGAL RELAY ATTEMPT" (553/550, a permanent failure) and
    the rest of the session ran without the user. The emails-per-day check
    re-read the record the same way.

    Re-read into a copy that only replaces the session's user record on
    success, and answer a failure with a 451 temporary error so the client
    retries.

    Seen with GitLab's notification mail: concurrent sessions for the same
    user stalled ~105 seconds in lockuserdat() and one was rejected as an
    illegal relay.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • From Rob Swindell (on Windows@VERT to Git commit to main/sbbs/m on Fri Nov 13 20:51:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/80c2a8b975ed9eeb70bea54f
    Modified Files:
    src/sbbs3/mailsrvr.cpp
    Log Message:
    mailsrvr: don't apply the request rate limit to POP3 commands

    Every command received in the POP3 TRANSACTION state was counted
    against the request rate limiter, so an authenticated client with a
    large mailbox (e.g. RETR + DELE for each of 250 messages) exceeded a
    500 request limit and was disconnected with "-ERR too many requests,
    try again later", logged as "Too many requests per rate limit".

    Those commands are only reachable after a successful login, failed
    logins are already handled by the login attempt filter, and concurrent connections are already limited, so the request rate limit now applies
    only to SMTP commands.

    The POP3 check was added in c8490b7429f (2026-03-11).

    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
  • From Rob Swindell (on Windows@VERT to Git commit to main/sbbs/m on Sat Nov 14 11:52:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/8195f1169c09075e219abebb
    Modified Files:
    src/sbbs3/mailsrvr.cpp
    Log Message:
    mailsrvr: never send a truncated POP3 LIST or UIDL listing

    The "list all" loop for LIST and UIDL stopped as soon as the mail base
    became locked, after "+OK" had been sent and before the terminating
    ".", so the client received a well-formed listing of only the first
    messages. A client that leaves mail on the server treats a message
    missing from the UIDL listing as removed, forgets it, and downloads it
    again as new on its next check: a session that collided with the
    daily e-mail purge caused 204 of 449 messages to be re-downloaded.

    The listing is now built first and sent only when every message was
    read; otherwise the reply is "-ERR" and the session ends. A failure to
    read a message's index or header also fails the listing, where before
    the message was silently left out.

    The lock check was added to the loop in 71aa48f825f (2026-01-16).

    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
  • From Rob Swindell (on Debian L@VERT to Git commit to main/sbbs/m on Sat Nov 21 11:03:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/808eb8cd0faf3682b5302148
    Modified Files:
    src/sbbs3/mailsrvr.cpp
    Log Message:
    mailsrvr: a delivery-failure notice names the failed message

    bounce() copied the failed message into the notice, so the notice's
    Message-ID was the failed message's own ID (or, when that had none, an
    ID derived from the failed message's number and time), and it carried
    no reply-ID. A mail client could not tell which sent message a notice
    was about, nor thread the notice under it.

    The notice now gets a Message-ID of its own, derived from a fresh
    message number, and the failed message's Message-ID as its reply-ID.
    When the failed message has no Message-ID the notice has no reply-ID.
    The guards against bouncing a notice are untouched.

    Verified by reading and compiling only; there is no automated test for
    this path. Built with GCC only.

    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>