• src/ssh/test/dssh_test.h

    From Deuc¿@VERT to Git commit to main/sbbs/m on Sunday, March 22, 2026 16:11:00
    https://gitlab.synchro.net/main/sbbs/-/commit/73b091e62b39ef31f4601784
    Added Files:
    src/ssh/test/dssh_test.h dssh_test_internal.h mock_io.c mock_io.h test_algo_enc.c test_algo_key.c test_algo_mac.c test_arch.c test_auth.c test_chan.c test_conn.c test_selftest.c test_transport.c
    Modified Files:
    src/ssh/CMakeLists.txt deucessh-conn.h server.c ssh-auth.c ssh-conn.c ssh-trans.c ssh-trans.h
    Log Message:
    DeuceSSH: 367-test suite, 6 bug fixes, channel request API redesign

    Test suite (13,000+ lines across 9 executables):
    - Tier 1 unit tests: arch (89), chan (75), algo_enc (23), algo_mac (18), algo_key (32)
    - Tier 2 layer tests: transport (63), auth (20), conn (33)
    - Tier 3 integration: selftest via socketpair (14)
    - CMake: DEUCESSH_BUILD_TESTS option, ctest integration
    - Infrastructure: dssh_test.h framework, mock_io bidirectional pipe layer,
    dssh_test_internal.h for DSSH_TESTABLE static function exposure

    Bug fixes found by the test suite:
    - ssh-trans.c: recv_packet KEXINIT handler caused recursive rekey during
    self-initiated rekey, sending duplicate KEXINIT that corrupted KEX
    - ssh-auth.c: auth_password/publickey/keyboard_interactive missing
    ensure_auth_service call (SERVICE_REQUEST never sent)
    - ssh-auth.c: server publickey verify computed wrong before_sig offset
    (rpos - sig_len - 4 instead of rpos - 4), failing all signature checks
    - ssh-trans.c: auto-rekey in recv_packet default case overwrote rx_packet
    while payload pointer was still live; deferred via rekey_pending flag
    - ssh-trans.c: kexinit failed on non-KEXINIT packets during rekey
    (application data arriving before peer's KEXINIT); now loops to skip
    - ssh-trans.c: DSSH_TESTABLE inline functions needed extern inline
    declarations for C17 linkage

    API redesign Ä dssh_server_session_cbs:
    - Replaced per-type callbacks (pty_req, env) with single
    dssh_channel_request_cb fired for every SSH_MSG_CHANNEL_REQUEST
    - Channel type deferred until terminal request: shell/exec creates
    DSSH_CHAN_SESSION (stream bytebufs), subsystem creates DSSH_CHAN_RAW
    (message queue) Ä both sides of subsystem now use raw I/O
    - Added parse helpers: dssh_parse_pty_req_data, dssh_parse_env_data,
    dssh_parse_exec_data, dssh_parse_subsystem_data

    Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT to Git commit to main/sbbs/m on Wednesday, March 25, 2026 23:06:00
    https://gitlab.synchro.net/main/sbbs/-/commit/bbeb4cfe06527973cc81a7b7
    Modified Files:
    src/ssh/test/dssh_test.h
    Log Message:
    Fix flaky rekey SIGPIPE: ignore SIGPIPE in test harness

    DH-GEX rekey selftests intermittently died from SIGPIPE when the
    demux thread's send() raced with the peer closing its socketpair
    end. MSG_NOSIGNAL on the mock I/O's send() only covers that
    specific call Ä the library's internal send path through the tx
    callback could still deliver SIGPIPE.

    Fix: signal(SIGPIPE, SIG_IGN) at test program startup, same as
    any network-facing application. send() returns EPIPE instead,
    which the library handles as a normal I/O error.

    Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT to Git commit to main/sbbs/m on Thursday, March 26, 2026 15:33:00
    https://gitlab.synchro.net/main/sbbs/-/commit/d7e507b99612587aa9224954
    Modified Files:
    src/ssh/test/dssh_test.h mock_io.c mock_io.h test_alloc.c test_auth.c test_conn.c test_transport.c test_transport_errors.c
    Log Message:
    Fix 6 thread-timing issues in test infrastructure

    1. Double-close race: mock_io_pipe fds now _Atomic int; close
    helpers use atomic_exchange for exactly one close() per fd.
    2. Add mock_io_close_s2c_write() for symmetry with c2s_write.
    3. Crafted server threads in test_auth.c now close pipes on all
    error paths (prevents peer hangs on early failure).
    4. All 122 bare thrd_create() calls checked: new ASSERT_THRD_CREATE
    macro in dssh_test.h; helper functions use inline checks.
    5. mock_io_drain uses recv(MSG_DONTWAIT) instead of toggling
    O_NONBLOCK via fcntl (per-call, no fd-flag side effects).

    Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT to Git commit to main/sbbs/m on Monday, March 30, 2026 14:17:00
    https://gitlab.synchro.net/main/sbbs/-/commit/cfaec21a7bc5812f2feb615b
    Modified Files:
    src/ssh/test/dssh_test.h test_conn.c
    Log Message:
    Fix test_conn 60s timeout bugs; add per-test timing to test framework

    Two reject tests (test_open_exec_rejected, test_setup_exec_rejected_by_callback)
    took 30s each because dssh_chan_accept loops back after rejection to wait for the next CHANNEL_OPEN. In tests, no more opens arrive, so the 30s accept_timeout
    fires. Fix: terminate the server session after joining the client thread to unblock the server's accept.

    test_accept_timeout_negative replaced its 50ms thrd_sleep with an atomic flag so the main thread proceeds as soon as the accept thread enters dssh_chan_accept.

    Reduced intentional-timeout safety margins to 1s (from 3-5s) in test_eof_half_close,
    test_accept_zc, and the four alloc sweep server threads.

    Added wall-clock timing to DSSH_TEST_MAIN: tests taking >100ms show duration
    in parentheses after PASS/FAIL/SKIP.

    Total dssh_conn_default time: ~5s (was ~78s).

    Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net