summaryrefslogtreecommitdiff
path: root/yhttpd/src/cli/cli.cpp
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-07-02 01:47:15 +0300
committerPaul Buetow <paul@buetow.org>2026-07-02 01:47:15 +0300
commit462e4ac6995760646b53e110f2662a6cd14fc882 (patch)
tree3acf0a34361cd4c48dfb27164eadf1d51823c1ca /yhttpd/src/cli/cli.cpp
parent5c744e37b6375f3f6842cdf3758a180a649bafea (diff)
ychat: add Mode B - embedded SQLite backend for real user accounts (task cs0)
Adds a second database backend alongside the (already-broken/dormant) MySQL one: --enable-sqlite (configure.ac/configure, mirrors --enable-mysql), USE_SQLITE (glob.h, mirrors USE_MYSQL), and a con/data implementation using sqlite3_prepare_v2/bind/step (parameterized queries - safer than the MySQL path's hand-rolled character-transliteration escaping). chat.database.dbname doubles as the SQLite file path; the "user" table is created on first connect (CREATE TABLE IF NOT EXISTS) since SQLite has no separate schema- provisioning step. New Dockerfile.sqlite (Mode B) builds and runs this in Rocky Linux 9; DOCKER-SQLITE.md documents everything in detail. DATABASE had never actually been compiled before this (Mode A always disables it, and --enable-mysql doesn't work - configure.ac registers it as AC_ARG_ENABLE(mysqlclient,...) but the gating check tests a third, never-set $enable_mysql - left alone, this task is about moving away from MySQL, not fixing it). Getting DATABASE to compile and actually run for the first time surfaced two real, previously-undetectable bugs, both fixed: - class data collided with std::data() (C++17) under "using namespace std" ("reference to 'data' is ambiguous") - renamed to ychatdb throughout (data.h/cpp, wrap.h/cpp, yc_register.cpp). Same bug class as the function->mod_func_t rename already made in glob.h. - data_base.cpp's config-query parser used "unsigned i_pos" for a string::npos comparison - truncating npos to 32-bit makes the "no more tokens" check never true, and i_pos+1 wraps back to 0, so the loop never advances: an infinite loop that OOM-killed the container within seconds of startup. Fixed to size_t (same bug class already fixed repeatedly in ../yhttpd). Verified in Docker: register creates a row, wrong password is rejected, correct password succeeds, and - the actual point of this task - a second user's login still works identically after a full container restart with the db file on a bind-mounted volume, proving persistence. Independently reproduced by a fresh-context review agent, which also rebuilt + re-verified the whole flow itself. Not deployed to f3s - this is a local proof of concept alongside the live Mode A (in-memory guest chat) deployment. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'yhttpd/src/cli/cli.cpp')
0 files changed, 0 insertions, 0 deletions