From 5b41a06d0cefc236f019fce5a440ff46aec27f2f Mon Sep 17 00:00:00 2001 From: Herwin Bozet Date: Tue, 17 Nov 2026 21:13:58 +0100 Subject: [PATCH] Merged bakashrot-cert into bakashrot as `bakashrot cert`, Made the programs smaller, Added a -HybridCrt switch - `bakashrot cert ca|issue|revoke|show` (same options) replaces bakashrot-cert: aws-lc, the C runtime and clap once, 2.53 MB instead of 2.85 + 1.73 MB on Windows; guides, docs, release.py, Docker updated - The tool built with its own profile, release-tools (panic = "abort", about 15% smaller); the DLL and the server keep unwind - clap without colours and suggestions (40 KB, 9 crates fewer) - SQLite without FTS3/FTS5, R-Tree, dbstat, STAT4, soundex(), extension loading and column metadata (LIBSQLITE3_FLAGS): the server 4.68 to 4.37 MB; a storage test checks they're out - build.ps1 / release.ps1 -HybridCrt (.cargo/hybrid-crt.toml): the UCRT from Windows, about 180 KB less per program, still nothing to install; static stays the default, README.txt says which - revamp.md: what was weighed and left (UPX, fully dynamic CRT, nightly options, OMIT_* flags), aws-lc kept over Graviola (490 KB bigger) and ring (no ML-KEM) Co-Authored-By: Claude Opus 5.5 --- .cargo/config.toml | 5 ++ .cargo/hybrid-crt.toml | 9 +++ Cargo.lock | 76 ----------------- Cargo.toml | 11 ++- bindings/python/bakashrot.py | 2 +- build.ps1 | 17 +++- building.md | 17 ++-- crates/bakashrot-config/example.toml | 2 +- crates/bakashrot-storage/tests/storage.rs | 22 +++++ crates/bakashrot-tools/Cargo.toml | 12 ++- .../src/{bin/bakashrot-cert.rs => cert.rs} | 36 ++------- .../src/{bin/bakashrot.rs => main.rs} | 16 +++- crates/bakashrot-tools/tests/cert.rs | 8 +- docker/Dockerfile | 17 ++-- docker/test.sh | 8 +- docs/certificates.md | 14 ++-- docs/client.md | 19 ++--- docs/lab.md | 16 ++-- docs/server.md | 10 ++- docs/storage.md | 9 ++- guides/1-certificates.md | 15 ++-- guides/2-server.md | 2 +- guides/readme.md | 4 +- release.ps1 | 6 +- release.py | 81 +++++++++++-------- revamp.md | 38 +++++++-- 26 files changed, 253 insertions(+), 219 deletions(-) create mode 100644 .cargo/hybrid-crt.toml rename crates/bakashrot-tools/src/{bin/bakashrot-cert.rs => cert.rs} (91%) rename crates/bakashrot-tools/src/{bin/bakashrot.rs => main.rs} (95%) diff --git a/.cargo/config.toml b/.cargo/config.toml index 4c36d2e..44243c5 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -9,3 +9,8 @@ rustflags = ["-C", "target-feature=+crt-static"] # 2026-11-14 (../revamp.md, "Randomness from the OS"; ../docs/certificates.md). [env] AWS_LC_SYS_NO_JITTER_ENTROPY = "1" +# SQLite (rusqlite's `bundled`) without what libsqlite3-sys turns on and +# nothing here uses: full-text search, R-Tree, dbstat, STAT4, soundex(), +# extension loading, column metadata. 310 KB less in the server (6.6%). +# Decided 2026-11-17 (../revamp.md, "One tool, smaller"; ../docs/storage.md). +LIBSQLITE3_FLAGS = "-USQLITE_ENABLE_FTS3 -USQLITE_ENABLE_FTS3_PARENTHESIS -USQLITE_ENABLE_FTS5 -USQLITE_ENABLE_RTREE -USQLITE_ENABLE_DBSTAT_VTAB -USQLITE_ENABLE_STAT4 -USQLITE_SOUNDEX -USQLITE_ENABLE_LOAD_EXTENSION -USQLITE_ENABLE_COLUMN_METADATA" diff --git a/.cargo/hybrid-crt.toml b/.cargo/hybrid-crt.toml new file mode 100644 index 0000000..98ebbb2 --- /dev/null +++ b/.cargo/hybrid-crt.toml @@ -0,0 +1,9 @@ +# The hybrid C runtime on Windows (MSVC), instead of the static one: the +# UCRT from Windows (part of it since Windows 10, which Rust needs anyway), +# VCRuntime still static. About 180 KB less per program, still no Visual +# C++ redistributable; measured 2026-11-17. Not the default (../revamp.md, +# "Decided" 2): build.ps1 -HybridCrt, release.ps1 -HybridCrt, or +# `cargo build --config .cargo/hybrid-crt.toml`. Cargo adds these flags to +# config.toml's (+crt-static stays). Switching rebuilds everything. +[target.'cfg(all(windows, target_env = "msvc"))'] +rustflags = ["-C", "link-arg=/NODEFAULTLIB:libucrt.lib", "-C", "link-arg=/DEFAULTLIB:ucrt.lib"] diff --git a/Cargo.lock b/Cargo.lock index 90697b0..9af9ae3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,56 +2,12 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "anstream" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - [[package]] name = "anstyle" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" -[[package]] -name = "anstyle-parse" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" -dependencies = [ - "windows-sys 0.61.2", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" -dependencies = [ - "anstyle", - "once_cell_polyfill", - "windows-sys 0.61.2", -] - [[package]] name = "asn1-rs" version = "0.7.2" @@ -304,10 +260,8 @@ version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d" dependencies = [ - "anstream", "anstyle", "clap_lex", - "strsim", ] [[package]] @@ -337,12 +291,6 @@ dependencies = [ "cc", ] -[[package]] -name = "colorchoice" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" - [[package]] name = "data-encoding" version = "2.11.1" @@ -526,12 +474,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "is_terminal_polyfill" -version = "1.70.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" - [[package]] name = "itoa" version = "1.0.19" @@ -674,12 +616,6 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" -[[package]] -name = "once_cell_polyfill" -version = "1.70.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" - [[package]] name = "pem" version = "4.0.0" @@ -973,12 +909,6 @@ dependencies = [ "rsqlite-vfs", ] -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - [[package]] name = "subtle" version = "2.6.1" @@ -1265,12 +1195,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" -[[package]] -name = "utf8parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" - [[package]] name = "vcpkg" version = "0.2.15" diff --git a/Cargo.toml b/Cargo.toml index cf75ca5..b349298 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,5 +34,14 @@ lto = true codegen-units = 1 strip = true # Kept on purpose: the C DLL catches panics at every export (catch_unwind), -# which "abort" would make impossible. +# which "abort" would make impossible, and the server loses only the +# connection that panicked (tokio catches it), not every one. panic = "unwind" + +# The tool (bakashrot), released with this (build.ps1, release.py, the +# Dockerfile): a panic ends its command either way, and without unwinding +# it's about 15% smaller (measured 2026-11-17 on Windows: 2.53 MB, its +# certificates' commands in it). Its own folder, target/release-tools/. +[profile.release-tools] +inherits = "release" +panic = "abort" diff --git a/bindings/python/bakashrot.py b/bindings/python/bakashrot.py index c85b635..a84e14e 100644 --- a/bindings/python/bakashrot.py +++ b/bindings/python/bakashrot.py @@ -16,7 +16,7 @@ stored, a str that may or may not be JSON: parsing them is up to the app print(message.id, message.json()) Who the client is comes from its certificate, issued by the CA the server -trusts (bakashrot-cert): its name is its node, its roles say what it may +trusts (bakashrot cert): its name is its node, its roles say what it may do. client.toml says where the server is and where the certificates are (docs/client.md): diff --git a/build.ps1 b/build.ps1 index 3505129..de0754f 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,7 +1,12 @@ -# Builds everything (the server, the tools, the client library), release -# mode, into target\release\. -# Usage: powershell -ExecutionPolicy Bypass -File build.ps1 +# Builds everything (the server, the tool, the client library), release +# mode, into target\release\: the tool with its own profile (release-tools, +# Cargo.toml) in target\release-tools\, then copied beside the others. +# -HybridCrt: the UCRT from Windows instead of linked in, about 180 KB less +# per program (.cargo/hybrid-crt.toml). +# Usage: powershell -ExecutionPolicy Bypass -File build.ps1 [-HybridCrt] +param([switch]$HybridCrt) $ErrorActionPreference = "Stop" +$crt = if ($HybridCrt) { @("--config", ".cargo/hybrid-crt.toml") } else { @() } # rustup's folder isn't always on the PATH (it isn't in every shell here). if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) { @@ -10,8 +15,12 @@ if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) { Push-Location $PSScriptRoot try { - cargo build --workspace --release --locked + cargo build --workspace --exclude bakashrot-tools --release --locked @crt if ($LASTEXITCODE -ne 0) { "FAILED: cargo build"; exit 1 } + cargo build -p bakashrot-tools --profile release-tools --locked @crt + if ($LASTEXITCODE -ne 0) { "FAILED: cargo build (the tool)"; exit 1 } + $tool = if ($IsLinux -or $IsMacOS) { "bakashrot" } else { "bakashrot.exe" } + Copy-Item (Join-Path "target\release-tools" $tool) "target\release" -Force } finally { Pop-Location } diff --git a/building.md b/building.md index bd963fc..92fd7a5 100644 --- a/building.md +++ b/building.md @@ -8,13 +8,13 @@ From the repository's root, on Windows (`powershell -ExecutionPolicy Bypass -Fil | Script | What it does | |---|---| -| `build.ps1` | Builds everything, release mode, into `target\release\` | +| `build.ps1` | Builds everything, release mode, into `target\release\` (the tool with the `release-tools` profile, copied there); `-HybridCrt` | | `test.ps1` | What CI runs: formatting, clippy (warnings are errors), the tests, the docs | -| `release.ps1` | A release for this platform, smoke-tested (`release.py`, below); `-SkipTest` | +| `release.ps1` | A release for this platform, smoke-tested (`release.py`, below); `-SkipTest`, `-HybridCrt` | | `clean.ps1` | Deletes `target\` (builds and releases) | | `bench.ps1` | The benchmarks, release mode: pushes, replication, storage (`docs/server.md`, "Measured"); `-Only`, `-Sync full` or `normal` | -Elsewhere, the same with cargo: `cargo build --release`, `cargo test`, `python release.py`, `cargo clean`; +Elsewhere, the same with cargo: `cargo build --release` (and `-p bakashrot-tools --profile release-tools`), `cargo test`, `python release.py`, `cargo clean`; the benchmarks are ignored tests (`cargo test --release -- --ignored`). Generated keys and certificates never go in git. @@ -23,7 +23,7 @@ Generated keys and certificates never go in git. A Cargo workspace: ``` -Cargo.toml the workspace: shared lints, release profile +Cargo.toml the workspace: shared lints, the release profiles (release-tools: the tool's) rust-toolchain.toml the pinned toolchain (1.100.0) build.ps1, test.ps1, release.ps1, clean.ps1, bench.ps1 release.py a release for this platform: build, package, smoke test @@ -37,23 +37,24 @@ crates/ bakashrot-server/ the server: TLS, identities, requests, the writer thread (and its program) bakashrot-client/ the client library, Rust API, blocking bakashrot-capi/ the C DLL over bakashrot-client: the BakaShrot_* exports (bakashrot.dll) - bakashrot-tools/ the CLI tools: bakashrot (push, read, query, list), bakashrot-cert + bakashrot-tools/ the CLI tool: bakashrot (push, read, query, list; cert: the certificates) bindings/ c/ bakashrot.h, generated from bakashrot-capi purebasic/ the prototypes and error codes python/ bakashrot.py over the DLL, check_bakashrot.py, make_wheel.py -.cargo/config.toml the C runtime linked statically on Windows +.cargo/config.toml the C runtime linked statically on Windows, SQLite's options +.cargo/hybrid-crt.toml -HybridCrt: the UCRT from Windows instead (about 180 KB less per program) docker/ the server's image: Dockerfile, compose.yml, test.sh ``` Dependencies only point downward: `proto`, `pki`, `config` and `storage` don't open sockets and are tested -on their own; `server` and `client` use them; the DLL and the tools only use `client`. +on their own; `server` and `client` use them; the DLL and the tool only use `client`. ## Releases `python release.py` (or `release.ps1`) on Windows or Linux, x64 or ARM64, builds that platform's release into `target/dist/bakashrot--/` and its archive (`.zip`, `.tar.gz`): -the server, `bakashrot`, `bakashrot-cert`, the client library with its C header and PureBasic prototypes, +the server, `bakashrot` (the certificates too: `bakashrot cert`), the client library with its C header and PureBasic prototypes, `bakashrot.py` and a wheel with the library in it (`bindings/python/make_wheel.py`), the example configs, `docs/`, a `README.txt`, the licenses (`THIRD-PARTY.txt`: every crate built in, from `cargo metadata`). diff --git a/crates/bakashrot-config/example.toml b/crates/bakashrot-config/example.toml index 14a3772..8d5e3b0 100644 --- a/crates/bakashrot-config/example.toml +++ b/crates/bakashrot-config/example.toml @@ -11,7 +11,7 @@ [server] listen = "0.0.0.0:7000" # required: address and port -# The certificates (bakashrot-cert), required. The node this server is, +# The certificates (bakashrot cert), required. The node this server is, # for its peers, is its certificate's name. ca = "ca.crt" certificate = "server-1.crt" diff --git a/crates/bakashrot-storage/tests/storage.rs b/crates/bakashrot-storage/tests/storage.rs index cd4c06e..2838c60 100644 --- a/crates/bakashrot-storage/tests/storage.rs +++ b/crates/bakashrot-storage/tests/storage.rs @@ -687,6 +687,28 @@ fn queries() { json("SELECT count(*) FROM messages")["rows"], serde_json::json!([["3"]]) ); + // SQLite without what nothing here uses (LIBSQLITE3_FLAGS in + // .cargo/config.toml): not built in, nor loadable. + for option in [ + "ENABLE_FTS3", + "ENABLE_FTS5", + "ENABLE_RTREE", + "ENABLE_DBSTAT_VTAB", + "ENABLE_STAT4", + "SOUNDEX", + "ENABLE_LOAD_EXTENSION", + "ENABLE_COLUMN_METADATA", + ] { + assert_eq!( + json(&format!("SELECT sqlite_compileoption_used('{option}')"))["rows"], + serde_json::json!([["0"]]), + "{option}" + ); + } + assert!(matches!( + runner.run("SELECT * FROM dbstat"), + Err(Error::Query(_)) + )); // A failing row fails it all, with SQLite's message. match runner.run("SELECT message_data ->> '$.t' FROM messages") { Err(Error::Query(why)) => assert!(why.contains("malformed JSON"), "{why}"), diff --git a/crates/bakashrot-tools/Cargo.toml b/crates/bakashrot-tools/Cargo.toml index c74036f..772bf1f 100644 --- a/crates/bakashrot-tools/Cargo.toml +++ b/crates/bakashrot-tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bakashrot-tools" -description = "BakaShrot's command-line tools: bakashrot pushes and reads messages, bakashrot-cert issues certificates and revokes them." +description = "BakaShrot's command-line tool: bakashrot pushes and reads messages, bakashrot cert issues certificates and revokes them." version.workspace = true edition.workspace = true rust-version.workspace = true @@ -9,17 +9,21 @@ authors.workspace = true repository.workspace = true publish.workspace = true -# No API to document, and its name is the DLL's library's (cargo doc would -# collide). +# One program, the certificates' commands in it (`bakashrot cert`): aws-lc, +# the C runtime and clap once, not in two programs. No API to document, and +# its name is the DLL's library's (cargo doc would collide). Released with +# the `release-tools` profile (../../Cargo.toml). [[bin]] name = "bakashrot" +path = "src/main.rs" doc = false [dependencies] bakashrot-client = { path = "../bakashrot-client" } bakashrot-pki = { path = "../bakashrot-pki" } bakashrot-proto = { path = "../bakashrot-proto" } -clap = { version = "4", features = ["derive"] } +# Without colours and "did you mean" suggestions: 40 KB less. +clap = { version = "4", default-features = false, features = ["std", "derive", "help", "usage", "error-context"] } serde = { version = "1.0.229", features = ["derive"] } serde_json = "1.0.154" time = "0.3.55" diff --git a/crates/bakashrot-tools/src/bin/bakashrot-cert.rs b/crates/bakashrot-tools/src/cert.rs similarity index 91% rename from crates/bakashrot-tools/src/bin/bakashrot-cert.rs rename to crates/bakashrot-tools/src/cert.rs index 8505920..0fa1fcd 100644 --- a/crates/bakashrot-tools/src/bin/bakashrot-cert.rs +++ b/crates/bakashrot-tools/src/cert.rs @@ -1,27 +1,16 @@ -//! `bakashrot-cert`: makes a CA, issues certificates, revokes them, shows -//! them. Every file is PEM; keys are written once, never over an existing -//! file. See `docs/certificates.md`. +//! `bakashrot cert`: makes a CA, issues certificates, revokes them, shows +//! them, with no server. Every file is PEM; keys are written once, never +//! over an existing file. See `docs/certificates.md`. use bakashrot_pki::{CA_DAYS, CERTIFICATE_DAYS, Ca, Identity, Revocations, Usage, summarize}; -use clap::{Parser, Subcommand}; +use clap::Subcommand; use std::fs; use std::io::Write; use std::path::{Path, PathBuf}; -use std::process::ExitCode; - -#[derive(Parser)] -#[command( - name = "bakashrot-cert", - version, - about = "Issues and revokes BakaShrot's certificates" -)] -struct Cli { - #[command(subcommand)] - command: Command, -} +// `bakashrot cert`'s commands (its help is `Command::Cert`'s, in main.rs). #[derive(Subcommand)] -enum Command { +pub enum Command { /// Makes a new CA: ca.crt and ca.key in --out. Keep ca.key off the /// servers: whoever has it can make any identity. Ca { @@ -85,17 +74,8 @@ enum Command { }, } -fn main() -> ExitCode { - match run(Cli::parse().command) { - Ok(()) => ExitCode::SUCCESS, - Err(error) => { - eprintln!("bakashrot-cert: {error}"); - ExitCode::FAILURE - } - } -} - -fn run(command: Command) -> Result<(), String> { +/// Runs one of `bakashrot cert`'s commands. +pub fn run(command: Command) -> Result<(), String> { match command { Command::Ca { name, days, out } => { let ca = Ca::create(&name, days).map_err(|e| e.to_string())?; diff --git a/crates/bakashrot-tools/src/bin/bakashrot.rs b/crates/bakashrot-tools/src/main.rs similarity index 95% rename from crates/bakashrot-tools/src/bin/bakashrot.rs rename to crates/bakashrot-tools/src/main.rs index 3e64ab9..a582d47 100644 --- a/crates/bakashrot-tools/src/bin/bakashrot.rs +++ b/crates/bakashrot-tools/src/main.rs @@ -1,6 +1,9 @@ //! `bakashrot`: pushes messages, reads them and their attachments, runs //! queries and lists names from the command line, connecting with a -//! `client.toml`; see `docs/client.md`, "The tools". +//! `client.toml`; see `docs/client.md`, "The tool". `bakashrot cert` +//! issues the certificates (`cert.rs`, `docs/certificates.md`). + +mod cert; use bakashrot_client::{Client, Error, Settings}; use bakashrot_proto::error::{code_name, is_refusal_code}; @@ -18,12 +21,12 @@ use std::time::Duration; #[command( name = "bakashrot", version, - about = "Pushes and reads BakaShrot's messages", + about = "Pushes and reads BakaShrot's messages, issues its certificates", after_help = "Exits with 0 on success, 1 on a failure, 2 on bad arguments." )] struct Cli { /// The client's settings: the server, the CA's certificate, this - /// client's certificate and key, the CRL. + /// client's certificate and key, the CRL (cert doesn't use them). #[arg(short, long, global = true, default_value = "client.toml")] config: PathBuf, #[command(subcommand)] @@ -110,6 +113,12 @@ enum Command { #[arg(long)] json: bool, }, + /// Makes a CA, issues certificates, revokes them, shows them; no + /// server needed (run it where the CA's key is). + Cert { + #[command(subcommand)] + command: cert::Command, + }, } /// Where `messages` starts. @@ -159,6 +168,7 @@ fn main() -> ExitCode { fn run(config: &Path, command: Command) -> Result<(), String> { match command { + Command::Cert { command } => cert::run(command)?, Command::Push { topic, message, diff --git a/crates/bakashrot-tools/tests/cert.rs b/crates/bakashrot-tools/tests/cert.rs index 116cf95..4fa5ec8 100644 --- a/crates/bakashrot-tools/tests/cert.rs +++ b/crates/bakashrot-tools/tests/cert.rs @@ -1,4 +1,4 @@ -//! `bakashrot-cert` end to end, in a folder of the build's. +//! `bakashrot cert` end to end, in a folder of the build's. use bakashrot_pki::{Revocations, summarize}; use std::fs; @@ -12,9 +12,11 @@ fn folder(name: &str) -> PathBuf { folder } -/// Runs the tool in `folder`: whether it succeeded, and what it printed. +/// Runs `bakashrot cert` in `folder`: whether it succeeded, and what it +/// printed. fn cert(folder: &Path, args: &[&str]) -> (bool, String) { - let output = Command::new(env!("CARGO_BIN_EXE_bakashrot-cert")) + let output = Command::new(env!("CARGO_BIN_EXE_bakashrot")) + .arg("cert") .args(args) .current_dir(folder) .output() diff --git a/docker/Dockerfile b/docker/Dockerfile index e888ee0..19d5702 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,6 @@ -# The BakaShrot server's image: bakashrot-server, with the bakashrot and -# bakashrot-cert tools beside it. Built from the repository's root: +# The BakaShrot server's image: bakashrot-server, with the bakashrot tool +# beside it (bakashrot cert for the certificates). Built from the +# repository's root: # docker build -f docker/Dockerfile -t bakashrot-server . # CI builds it for amd64 and arm64 on a version tag, checks it # (docker/test.sh) and pushes it to ghcr.io/aziascreations/bakashrot-server @@ -12,7 +13,7 @@ # from outside the container # database = "/var/lib/bakashrot/bakashrot.sqlite" # and the certificates relative to it (ca = "ca.crt", ...). The server runs -# as uid 10001, which must be able to read its key (bakashrot-cert writes +# as uid 10001, which must be able to read its key (bakashrot cert writes # keys readable by their owner only): chown 10001:10001 config/server-1.key # # docker run -d --name bakashrot -p 7000:7000 \ @@ -20,7 +21,7 @@ # ghcr.io/aziascreations/bakashrot-server # # Or docker/compose.yml. `docker stop` stops it cleanly (SIGTERM). -# The tools: docker run --rm bakashrot-cert ... (or bakashrot ...). +# The tool: docker run --rm bakashrot cert ... (or bakashrot push ...). # --- Build --------------------------------------------------------------------- @@ -30,11 +31,13 @@ FROM rust:1-slim-trixie AS build WORKDIR /src # Only what the programs are built from (Dockerfile.dockerignore). COPY . . -# The toolchain rust-toolchain.toml pins, then the release build. +# The toolchain rust-toolchain.toml pins, then the release build, the tool +# with its own profile (release-tools, Cargo.toml). RUN rustup toolchain install \ - && cargo build --release --locked -p bakashrot-server -p bakashrot-tools \ + && cargo build --release --locked -p bakashrot-server \ + && cargo build --profile release-tools --locked -p bakashrot-tools \ && mkdir /out \ - && cp target/release/bakashrot-server target/release/bakashrot target/release/bakashrot-cert /out/ + && cp target/release/bakashrot-server target/release-tools/bakashrot /out/ # --- Runtime ------------------------------------------------------------------- diff --git a/docker/test.sh b/docker/test.sh index f8f5661..24555c1 100755 --- a/docker/test.sh +++ b/docker/test.sh @@ -1,6 +1,6 @@ #!/bin/sh # Smoke-tests a server image, as CI does before pushing it: certificates by -# its bakashrot-cert, its server started with them, its bakashrot pushing +# its bakashrot cert, its server started with them, its bakashrot pushing # and reading back over a Docker network, then `docker stop`, which must # end it cleanly (exit code 0, "stopped"). # Usage: docker/test.sh @@ -27,9 +27,9 @@ tool() { } docker network create "$name" >/dev/null -tool bakashrot-cert ca --name "Image test CA" -tool bakashrot-cert issue --name server-1 --server -tool bakashrot-cert issue --name tester --role tester +tool bakashrot cert ca --name "Image test CA" +tool bakashrot cert issue --name server-1 --server +tool bakashrot cert issue --name tester --role tester cat >"$work/server.toml" < with an attachment, reading both back (run by hand against a server; not in CI, which has no PureBasic). -## The tools +## The tool -`bakashrot`, one program to push, read, query and list (`bakashrot-cert`, -for the CA, is apart: `certificates.md`). Each command connects with -`-c ` (`client.toml` by default), does one thing and exits: 0, 1 on a -failure (why on stderr: `Refused by the server (NotAllowed): ...`, -`Failed to connect to ...`), 2 on bad arguments. `--help` on each. +`bakashrot`, one program to push, read, query and list, and to make the +certificates (`bakashrot cert`, no server needed: `certificates.md`). +Each other command connects with `-c ` (`client.toml` by default), +does one thing and exits: 0, 1 on a failure (why on stderr: `Refused by +the server (NotAllowed): ...`, `Failed to connect to ...`), 2 on bad +arguments. `--help` on each. ```text bakashrot push logs '{"t":21}' Pushed as message #42 diff --git a/docs/lab.md b/docs/lab.md index 4bf2d91..40609b9 100644 --- a/docs/lab.md +++ b/docs/lab.md @@ -10,7 +10,7 @@ example configs. | Machine | What runs there | Files it gets | |---|---|---| -| admin (any) | `bakashrot-cert` | `ca.key` stays here, never copied | +| admin (any) | `bakashrot cert` | `ca.key` stays here, never copied | | server-1 | `bakashrot-server` | `ca.crt`, `server-1.crt`, `server-1.key`, `server.toml` | | server-2 | `bakashrot-server` | `ca.crt`, `server-2.crt`, `server-2.key`, `server.toml` | | kitchen | `bakashrot` (pushes to server-1) | `ca.crt`, `kitchen.crt`, `kitchen.key`, `client.toml` | @@ -23,12 +23,12 @@ their hostnames or IPs. The clients can be on the servers' machines. ## 1. The certificates (admin) ``` -bakashrot-cert ca --name "Lab CA" -bakashrot-cert issue --name server-1 --role peer --server -bakashrot-cert issue --name server-2 --role peer --server -bakashrot-cert issue --name kitchen --role sensor -bakashrot-cert issue --name dashboard --role dashboard -bakashrot-cert issue --name lab-py --role sensor --role dashboard +bakashrot cert ca --name "Lab CA" +bakashrot cert issue --name server-1 --role peer --server +bakashrot cert issue --name server-2 --role peer --server +bakashrot cert issue --name kitchen --role sensor +bakashrot cert issue --name dashboard --role dashboard +bakashrot cert issue --name lab-py --role sensor --role dashboard ``` A certificate is its name (the node) and its roles; the servers' configs @@ -154,7 +154,7 @@ Failed to connect to server-1.lab:7000 (NotAllowed): none of visitor's roles (gu takes them; it logs once that server-2 refused), start server-2: within about 10 s every one is on dashboard, in order. -**Revoking.** On admin, `bakashrot-cert revoke dashboard.crt` writes +**Revoking.** On admin, `bakashrot cert revoke dashboard.crt` writes `ca.crl`; copy it next to each server's `server.toml` (the `crl` above). Within 5 s they reload it (`INFO ca.crl: reloaded, 1 revoked`), and the certificate is refused, at its next connection or request: diff --git a/docs/server.md b/docs/server.md index 24dd8fa..fc2bc9f 100644 --- a/docs/server.md +++ b/docs/server.md @@ -50,12 +50,13 @@ Restart=on-failure `docker/Dockerfile` (its comments have the details), the image `ghcr.io/aziascreations/bakashrot-server` (amd64 and arm64, pushed by CI -on a version tag): the server, with `bakashrot` and `bakashrot-cert` -beside it, on `debian:trixie-slim`, as uid 10001. +on a version tag): the server, with the `bakashrot` tool beside it +(`bakashrot cert` for the certificates), on `debian:trixie-slim`, as +uid 10001. - **The config** in `/etc/bakashrot`, read-only: `server.toml`, the certificates, the server's key (readable by uid 10001: `chown 10001` - it, `bakashrot-cert` writes keys for their owner only). `listen = + it, `bakashrot cert` writes keys for their owner only). `listen = "0.0.0.0:7000"`: 127.0.0.1 isn't reachable from outside. - **The database** in `/var/lib/bakashrot`, a volume: `database = "/var/lib/bakashrot/bakashrot.sqlite"`. @@ -64,7 +65,8 @@ beside it, on `debian:trixie-slim`, as uid 10001. 7000:7000 -v ./config:/etc/bakashrot:ro -v bakashrot-data:/var/lib/bakashrot `. `docker stop` is SIGTERM: a clean stop. The logs: `docker logs`. -- **The tools:** `docker run --rm bakashrot-cert ...`. +- **The tool:** `docker run --rm bakashrot cert ...` (or + `bakashrot push ...`). - **Checked** by `docker/test.sh ` (CI runs it on both before pushing): certificates by the image's tool, its server, a push read back over a Docker network, `docker stop` ending it cleanly. diff --git a/docs/storage.md b/docs/storage.md index a49702a..512cd16 100644 --- a/docs/storage.md +++ b/docs/storage.md @@ -159,6 +159,9 @@ SELECT * FROM messages WHERE topic = 'logs' AND node = 'kitchen' SELECT message_data ->> '$.temp' FROM messages WHERE topic = 'sensors' AND is_json = 1 ``` +SQLite's functions are there, JSON's included; not `soundex()` nor the +`dbstat` table (left out of the build, "The file"). + - **By topic, or topic and node:** ranges of the table, read in order (a test checks the plans). - **Filters on `pushed_at` or `message_id`** read the streams they're in, @@ -182,7 +185,11 @@ SELECT message_data ->> '$.temp' FROM messages WHERE topic = 'sensors' AND is_js foreign keys: one writer keeps the tables consistent, `CHECK`s keep the values valid. - SQLite is compiled in (`rusqlite`'s `bundled`): the same version - everywhere, no system library. + everywhere, no system library. Without full-text search (FTS3, FTS5), + R-Tree, `dbstat`, STAT4, `soundex()`, extension loading and column + metadata, which libsqlite3-sys turns on and nothing here uses: 310 KB + less in the server (`LIBSQLITE3_FLAGS` in `../.cargo/config.toml`; a + test checks they're out). JSON is SQLite's own, always there. ## Measured diff --git a/guides/1-certificates.md b/guides/1-certificates.md index c7f902f..5734165 100644 --- a/guides/1-certificates.md +++ b/guides/1-certificates.md @@ -2,13 +2,14 @@ [Index](readme.md) ยท Next: [Server](2-server.md) -More options: `bakashrot-cert.exe --help`. +Made by `bakashrot.exe`'s `cert` commands, with no server needed. +More options: `bakashrot.exe cert --help`. ## The root certificate ```shell -bakashrot-cert.exe ca --name bakashrot-test +bakashrot.exe cert ca --name bakashrot-test ``` Resulting files: @@ -19,7 +20,7 @@ Resulting files: ## A server certificate ```shell -bakashrot-cert.exe issue --server --name server-lan1 +bakashrot.exe cert issue --server --name server-lan1 Wrote .\server-lan1.crt Wrote .\server-lan1.key ``` @@ -31,11 +32,11 @@ See [???](). ## Node certificates ```shell -bakashrot-cert.exe issue --name node-sensor --role sensor +bakashrot.exe cert issue --name node-sensor --role sensor Wrote .\node-sensor.crt Wrote .\node-sensor.key -bakashrot-cert.exe issue --name node-viewer --role viewer +bakashrot.exe cert issue --name node-viewer --role viewer Wrote .\node-viewer.crt Wrote .\node-viewer.key ``` @@ -48,7 +49,7 @@ Wrote .\node-viewer.key ## Checking one ```shell -bakashrot-cert.exe show node-sensor.crt +bakashrot.exe cert show node-sensor.crt node-sensor.crt name: node-sensor roles: sensor @@ -62,7 +63,7 @@ node-sensor.crt ## Revoking one ```shell -bakashrot-cert.exe revoke node-sensor.crt +bakashrot.exe cert revoke node-sensor.crt ``` * Writes `ca.crl` (every certificate revoked so far). diff --git a/guides/2-server.md b/guides/2-server.md index 1792845..57d5a9b 100644 --- a/guides/2-server.md +++ b/guides/2-server.md @@ -115,7 +115,7 @@ accept_nodes = ["*"] # Accepts every foreign node's messages (Default) > list_topics = true > list_nodes = true > ``` -> Its certificate: `bakashrot-cert.exe issue --name node-admin --role admin` +> Its certificate: `bakashrot.exe cert issue --name node-admin --role admin` ### Retention diff --git a/guides/readme.md b/guides/readme.md index aeb2e39..54933ca 100644 --- a/guides/readme.md +++ b/guides/readme.md @@ -15,12 +15,12 @@ Who gets which files: | Machine | Files | |---------|---------------------------------------------------------------------------------------| -| admin | `bakashrot-cert.exe`, `ca.crt`, `ca.key` (never copied) | +| admin | `bakashrot.exe` (its `cert` commands), `ca.crt`, `ca.key` (never copied) | | server | `bakashrot-server.exe`, `ca.crt`, `server-lan1.crt`, `server-lan1.key`, `server.toml` | | sensor | `bakashrot.exe`, `ca.crt`, `node-sensor.crt`, `node-sensor.key`, `client.toml` | | viewer | `bakashrot.exe`, `ca.crt`, `node-viewer.crt`, `node-viewer.key`, `viewer.toml` | More: -* `bakashrot --help`, `bakashrot-cert --help`. +* `bakashrot --help`, `bakashrot cert --help`. * Two replicating servers, Python, Docker: `docs/lab.md`. * Every setting: `docs/config.md`. diff --git a/release.ps1 b/release.ps1 index 2320146..0596df0 100644 --- a/release.ps1 +++ b/release.ps1 @@ -1,12 +1,14 @@ # A release for this platform, built, packaged and smoke-tested, into # target\dist\ (release.py, Python 3.11+, does it all). -# Usage: powershell -ExecutionPolicy Bypass -File release.ps1 [-SkipTest] -param([switch]$SkipTest) +# Usage: powershell -ExecutionPolicy Bypass -File release.ps1 [-SkipTest] [-HybridCrt] +# (-HybridCrt: the UCRT from Windows, see release.py's --hybrid-crt) +param([switch]$SkipTest, [switch]$HybridCrt) $ErrorActionPreference = "Stop" # The py launcher if it's there, python otherwise. $python = if (Get-Command py -ErrorAction SilentlyContinue) { @("py", "-3") } else { @("python") } $arguments = @(Join-Path $PSScriptRoot "release.py") if ($SkipTest) { $arguments += "--skip-test" } +if ($HybridCrt) { $arguments += "--hybrid-crt" } & $python[0] @($python | Select-Object -Skip 1) @arguments exit $LASTEXITCODE diff --git a/release.py b/release.py index eebb536..7754d4e 100644 --- a/release.py +++ b/release.py @@ -1,11 +1,11 @@ """Builds a BakaShrot release for this machine's platform (Windows or Linux, x64 or ARM64), checks it works, and archives it: - python release.py [--skip-test] + python release.py [--skip-test] [--hybrid-crt] Into target/dist/: bakashrot--/ the release: - bakashrot-server, bakashrot, bakashrot-cert the programs + bakashrot-server, bakashrot the programs bakashrot.dll / libbakashrot.so the client library (C) include/bakashrot.h its C header purebasic/*.pbi its PureBasic prototypes @@ -17,17 +17,21 @@ Into target/dist/: LICENSE.txt, THIRD-PARTY.txt BakaShrot's (CC0), its dependencies' bakashrot--.zip (Windows) or .tar.gz (Linux) -No keys or certificates in it: bakashrot-cert makes them. +No keys or certificates in it: bakashrot cert makes them. The check (unless --skip-test), in the release folder's _test/ (exes run from temp folders get blocked by antivirus here), deleted after unless -it failed: a CA and certificates by bakashrot-cert, the +it failed: a CA and certificates by bakashrot cert, the server started on a free port with a throwaway database, then the tool pushing (and an attachment of 3 MB), reading back, listing, querying; Python through the library, then the wheel installed by pip and used with no path given; then the server stopped as a service manager would (SIGTERM, or Ctrl+Break on Windows), which must end cleanly. +--hybrid-crt, on Windows: the C runtime's UCRT from Windows (10 and up) +instead of linked in, about 180 KB less per program, still no Visual C++ +redistributable (.cargo/hybrid-crt.toml); README.txt says which. + The version is the workspace's (Cargo.toml), which bakashrot.py's __version__ must match. Needs Python 3.11+ (tomllib) and cargo (rustup). """ @@ -49,16 +53,17 @@ HERE = os.path.dirname(os.path.abspath(__file__)) WINDOWS = sys.platform == "win32" EXE = ".exe" if WINDOWS else "" LIBRARY = "bakashrot.dll" if WINDOWS else "libbakashrot.so" -PROGRAMS = ["bakashrot-server", "bakashrot", "bakashrot-cert"] -CRATES = ["bakashrot-server", "bakashrot-tools", "bakashrot-capi"] +# Each built with its profile (Cargo.toml), into target//. +PROGRAMS = {"bakashrot-server": "release", "bakashrot": "release-tools"} +CRATES = {"bakashrot-server": "release", "bakashrot-capi": "release", "bakashrot-tools": "release-tools"} CLIENT_EXAMPLE = """\ # What the bakashrot tool and Python's Client.from_file() read, to connect # to a server. Paths are relative to this file's folder. See # docs/client.md. server = "10.0.0.2:7000" # host:port, [an IPv6 address]:port -ca = "ca.crt" # the CA's certificate (bakashrot-cert ca) -certificate = "kitchen.crt" # this node's (bakashrot-cert issue --name kitchen ...) +ca = "ca.crt" # the CA's certificate (bakashrot cert ca) +certificate = "kitchen.crt" # this node's (bakashrot cert issue --name kitchen ...) key = "kitchen.key" # crl = "ca.crl" # optional: certificates the CA revoked """ @@ -162,13 +167,17 @@ def third_party(): return "\n".join(lines) + "\n" -def readme(version, name): +def readme(version, name, hybrid): built = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M UTC") rustc = run(["rustc", "--version"]).strip() + crt = "" + if WINDOWS: + crt = ("\nThe C runtime: Windows' UCRT (Windows 10 and up), VCRuntime linked in." + if hybrid else "\nThe C runtime: linked in, nothing to install.") return f"""\ BakaShrot {version} ({name}) -Built {built}, commit {commit()}, {rustc}. +Built {built}, commit {commit()}, {rustc}.{crt} Licenses: BakaShrot is CC0 (LICENSE.txt); the crates built into it are listed in THIRD-PARTY.txt with their licenses. @@ -177,11 +186,11 @@ from clients with certificates of your own CA, store them in SQLite, and replicate them between servers. docs/ has the details (config.md, certificates.md, server.md, client.md, protocol.md). -Certificates (bakashrot-cert{EXE}; docs/certificates.md): - bakashrot-cert ca --name "Home CA" ca.crt, ca.key (keep ca.key safe) - bakashrot-cert issue --name server-1 --server a server's - bakashrot-cert issue --name kitchen --role sensor a client's: its node, its roles - bakashrot-cert revoke kitchen.crt ca.crl +Certificates (bakashrot{EXE} cert, no server needed; docs/certificates.md): + bakashrot cert ca --name "Home CA" ca.crt, ca.key (keep ca.key safe) + bakashrot cert issue --name server-1 --server a server's + bakashrot cert issue --name kitchen --role sensor a client's: its node, its roles + bakashrot cert revoke kitchen.crt ca.crl The server (bakashrot-server{EXE} server.toml; docs/config.md, server.md): server.example.toml has every setting. It logs to the console @@ -208,20 +217,25 @@ release: another version's connection is refused. Nothing from the old """ -def build(): - print("Building") - command = ["cargo", "build", "--release", "--locked"] - for crate in CRATES: - command += ["-p", crate] - run(command) - return os.path.join(HERE, "target", "release") +def build(hybrid): + """Each profile's crates at once; the folder of a profile's output.""" + print("Building" + (" (the hybrid C runtime)" if hybrid else "")) + for profile in sorted(set(CRATES.values())): + command = ["cargo", "build", "--profile", profile, "--locked"] + if hybrid: + command += ["--config", os.path.join(".cargo", "hybrid-crt.toml")] + for crate, its in CRATES.items(): + if its == profile: + command += ["-p", crate] + run(command) + return lambda profile: os.path.join(HERE, "target", profile) -def package(built, version, name, out): +def package(built, version, name, out, hybrid): print(f"Packaging {out}") - for program in PROGRAMS: - shutil.copy2(os.path.join(built, program + EXE), out) - shutil.copy2(os.path.join(built, LIBRARY), out) + for program, profile in PROGRAMS.items(): + shutil.copy2(os.path.join(built(profile), program + EXE), out) + shutil.copy2(os.path.join(built(CRATES["bakashrot-capi"]), LIBRARY), out) bindings = os.path.join(HERE, "bindings") os.makedirs(os.path.join(out, "include")) shutil.copy2(os.path.join(bindings, "c", "bakashrot.h"), os.path.join(out, "include")) @@ -234,7 +248,7 @@ def package(built, version, name, out): write(os.path.join(out, "client.example.toml"), CLIENT_EXAMPLE) shutil.copy2(os.path.join(HERE, "LICENSE"), os.path.join(out, "LICENSE.txt")) write(os.path.join(out, "THIRD-PARTY.txt"), third_party()) - write(os.path.join(out, "README.txt"), readme(version, name)) + write(os.path.join(out, "README.txt"), readme(version, name, hybrid)) wheel = run([sys.executable, "-B", os.path.join(bindings, "python", "make_wheel.py"), os.path.join(out, LIBRARY), os.path.join(out, "python"), os.path.join(out, "LICENSE.txt"), os.path.join(out, "THIRD-PARTY.txt")]).strip() @@ -264,9 +278,9 @@ def smoke_test(out, wheel): if not re.search(pattern, got, re.MULTILINE): fail(f"{what}: unexpected output:\n{got}") - tool("bakashrot-cert", "ca", "--name", "Release test CA") - tool("bakashrot-cert", "issue", "--name", "server-1", "--server") - tool("bakashrot-cert", "issue", "--name", "tester", "--role", "tester") + tool("bakashrot", "cert", "ca", "--name", "Release test CA") + tool("bakashrot", "cert", "issue", "--name", "server-1", "--server") + tool("bakashrot", "cert", "issue", "--name", "tester", "--role", "tester") port = free_port() write(os.path.join(test, "server.toml"), f"""\ [server] @@ -328,7 +342,7 @@ key = "tester.key" expect("query", tool("bakashrot", "query", "SELECT message_data ->> '$.value' AS v FROM messages WHERE topic = 'releasetest' AND message_id = 1"), r'"rows":\[\["42"\]\]') - print(" The tools: pushed, an attachment too, read back, listed, queried: OK") + print(" The tool: certificates made, pushed, an attachment too, read back, listed, queried: OK") script = ("import sys; sys.path.insert(0, sys.argv[1]); import bakashrot\n" "with bakashrot.Client.from_file('client.toml', sys.argv[2]) as c:\n" @@ -382,7 +396,7 @@ def archive(out): def main(): args = set(sys.argv[1:]) - if args - {"--skip-test"}: + if args - {"--skip-test", "--hybrid-crt"}: sys.exit(__doc__) # rustup's folder isn't on every shell's PATH. os.environ["PATH"] = os.path.join(os.path.expanduser("~"), ".cargo", "bin") + os.pathsep + os.environ["PATH"] @@ -398,7 +412,8 @@ def main(): os.remove(old) os.makedirs(out) print(f"BakaShrot {release} for {name}, into {out}") - wheel = package(build(), release, name, out) + hybrid = "--hybrid-crt" in args + wheel = package(build(hybrid), release, name, out, hybrid) if "--skip-test" not in args: shutil.rmtree(smoke_test(out, wheel)) print(f"Archive: {archive(out)}") diff --git a/revamp.md b/revamp.md index 5499739..d2efe5d 100644 --- a/revamp.md +++ b/revamp.md @@ -2,7 +2,7 @@ Started 2026-11-13: what it should change, what's decided, what's still open, and the plan. Every step of the plan is done (the workspace, -`bakashrot-proto`, `bakashrot-pki` and `bakashrot-cert`, +`bakashrot-proto`, `bakashrot-pki` and the certificate tool, `bakashrot-config`, `bakashrot-storage`, `bakashrot-server` and `bakashrot-client` answering every request, attachments included, the C DLL with its C, PureBasic and Python bindings, the `bakashrot` tool, @@ -30,7 +30,12 @@ test runner, CI, Docker, `bench.ps1`), see "Plan". unloaded (`BakaShrot_UnloadClient()`) and Windows' loader lock is never in the way; - the C runtime linked statically on Windows (`+crt-static`), built - against an old glibc on Linux (manylinux); + against an old glibc on Linux (manylinux); a switch for the hybrid + one, not the default (2026-11-17): `build.ps1` / `release.ps1 + -HybridCrt`, `.cargo/hybrid-crt.toml`, the UCRT from Windows (10 + and up), VCRuntime still linked in, about 180 KB less per program, + still nothing to install (fully dynamic: 21 KB less again, but + `vcruntime140.dll`, the redistributable's); - `W` exports take UTF-16 everywhere (PureBasic's strings; `wchar_t` is 32 bits on Linux); - the toolchain pinned (`rust-toolchain.toml`), a C header generated @@ -112,7 +117,7 @@ Also decided (2026-11-13): config (warned in its log: a CRL deleted by mistake) and `client.toml` (the tool, Python's `from_file()`). A path given to the DLL's `SetCrl` or Python's `Client(crl=...)` is asked for - explicitly: missing, it's a `FileError`. `bakashrot-cert revoke` + explicitly: missing, it's a `FileError`. `bakashrot cert revoke` needs no file to start from (it writes the first one). A file that's there but can't be read or isn't the CA's is refused; - clients check it too when given one (`client_config()` takes the @@ -120,7 +125,7 @@ Also decided (2026-11-13): block each other whichever end dials; - revoked by certificate, not by name: each certificate has its own key and serial number, so two servers of the same name each have theirs, - revoked one at a time (`bakashrot-cert issue --file`). + revoked one at a time (`bakashrot cert issue --file`). - **The server's config is TOML** (2026-11-13), `docs/config.md`: - `[server]`, `[retention]`, `[replication]`, `[roles.]`; unknown keys refused; names only (no ids, pins or ranges); @@ -190,7 +195,7 @@ Also decided (2026-11-13): - **The tools** (2026-11-14), `docs/client.md`, "The tools": one `bakashrot` program with subcommands (`push`, `latest`, `messages`, `query`, `list`) over `bakashrot-client`, `bakashrot-cert` kept apart - (the CA's key); `-c/--config`, `client.toml` by default; the old tools' + (the CA's key; folded in as `bakashrot cert` on 2026-11-17, below); `-c/--config`, `client.toml` by default; the old tools' output; messages and SQL inline, `@file` or `-` (standard input); exit codes 0, 1, and 2 for bad arguments. - **Attachments** (2026-11-14), `docs/server.md` and `client.md`: @@ -270,6 +275,29 @@ Also decided (2026-11-13): manual runs only, a read-only token but where images are pushed (after they're built and checked), no token left on disk by checkout, actions pinned to commits, `--locked` builds. +- **One tool, smaller** (2026-11-17), `docs/certificates.md`, "The + tool", and `docs/storage.md`, "The file": `bakashrot-cert` folded + into `bakashrot` as `bakashrot cert` (`ca`, `issue`, `revoke`, `show`, + the same options): aws-lc, the C runtime and clap once, 2.53 MB + instead of 2.85 + 1.73 MB on Windows. + The tool is built with its own profile, `release-tools` (`panic = + "abort"`, about 15% smaller); the DLL keeps `unwind` (it catches + panics), the server too (a panic loses one connection, not all). + clap without colours and "did you mean" suggestions (40 KB). SQLite + without what libsqlite3-sys turns on and nothing uses (FTS3, FTS5, + R-Tree, `dbstat`, STAT4, `soundex()`, extension loading, column + metadata; `LIBSQLITE3_FLAGS` in `.cargo/config.toml`): the server 4.68 + to 4.37 MB. Weighed and left: UPX (antivirus), the C runtime as a DLL + (Decided 2), a nightly `build-std` or `trim-paths`, `opt-level = "z"` + (5% for slower code), SQLite's `OMIT_*` options (7 KB), a TLS setup + naming P-384 only (25 KB: aws-lc links its other algorithms anyway). + **aws-lc kept** (the owner, 2026-11-17), the others measured with the + same TLS setup: Graviola (rustls-graviola 0.4.0, X25519MLKEM768 too) + 490 KB bigger, its P-256 and P-384 tables in it, and very new; ring + 410 KB smaller per program but without ML-KEM, which protects what's + recorded today from a quantum computer later; RustCrypto's provider + not for production. Worth another look if rustls-graviola lets a + provider name its algorithms one by one, or ring gets ML-KEM. ## Proposed, to confirm