https://gitlab.synchro.net/main/sbbs/-/commit/b0840112cf7fc427580fcd01
Modified Files:
docs/v322_new.md src/sbbs3/answer.cpp userdat.c userdat.h
Log Message:
User lookups: a missing user file is not an error; skip a partial index record
7ecf0b0786 (chat-28-roof, 2026-10-28) made matchuser_ex() and
finduserstr_ex() report a user base that could not be searched as a
USER_* error instead of "no such user" (#1307). Two cases it also
turned into errors:
- A user file that does not exist. On a new system with no users yet,
every login lookup failed as an error: SSH refused new-user sign-up
(so the first account could not be created over SSH), every SMTP
recipient got "451 4.3.0 User lookup failed" instead of a bounce, and
the terminal login showed "ERROR READ user base". finduserstr_ex()
now returns 0 when user.tab does not exist, and matchuser_ex() returns
0 for a missing name index when there are no users; with users in
user.tab, a missing index still is an error (their names cannot be
searched).
- An incomplete record at the end of the name index (after a crash, or
read while a new user is being appended). Every name not found before
it got USER_READ_ERROR, so every unknown user and every recipient who
is not a user failed as an error until the file was repaired. Whole
records only are read now and an incomplete last one is ignored; the
match test after the loop uses the same bound, so it does not return
the bogus user number the short read used to produce.
Also, a login by user number could not report an unreadable user base: lastuser() returns 0 both for no users and for a user.tab whose size
cannot be read, so find_login_id() answered "no such user" and the
servers counted a failed login. New lastuser_ex() returns a negative USER_STAT_ERROR (flength() uses stat(), not open()) for that, or 0
when user.tab does not exist; lastuser() clamps it as before, and find_login_id() passes it back like a name lookup's error.
The SSH login logs a failure to read the user's record at LOG_ERR (was LOG_NOTICE, without the result) and clears useron.number, as the
RLogin path does.
Tested by calling find_login_id() and lastuser_ex() against: no user
files (now 0 for number and name; name was -102), an unreadable user
directory (number now -111; was 0), users with the name index missing
(-102, unchanged), an index ending in a partial record (an unknown name
now 0; was -105; known names still found), and the live user base.
Co-Authored-By: Claude Opus 5.5 <
noreply@anthropic.com>
---
■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net