Commit Graph

27 Commits

Author SHA1 Message Date
b985db14ff fix(core/#421): dirs-guard re-asserts /run/secubox 1777 root:root (RuntimeDirectory churn)
Some checks are pending
License Headers / check (push) Waiting to run
90+ services declare RuntimeDirectory=secubox, so systemd re-chowns the shared
socket parent to secubox:secubox 0755 on each start, locking out non-secubox
socket creators. Removing explicit chowns (#494) wasn't enough; the per-minute
dirs-guard now self-heals /run/secubox centrally instead of editing 90+ units.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 10:04:31 +02:00
039824dcfa fix(core): stop secubox-core.service clobbering /run/secubox perms (ref #494)
secubox-core.service ran After=network.target, so its ExecStart
'chown secubox:secubox /run/secubox + chmod 775' fired LAST — after
secubox-runtime.service had re-applied the canonical tmpfiles rule
'd /run/secubox 1777 root root'. Result: the socket dir ended up
secubox:secubox, non-secubox daemons lost parent +x, and their sockets 502'd.

- Remove the chown/chmod of /run/secubox from ExecStart; the dir is now owned
  solely by tmpfiles.d (1777 root root) + secubox-runtime.service. This unit
  keeps only the www-data group membership.
- postinst defensively removes a stale non-dpkg-owned /etc/tmpfiles.d/secubox.conf
  declaring /run/secubox as 0775 secubox secubox (it overrode /usr/lib canonical).
- Ensure /var/log/suricata exists (0755) so ReadWritePaths services don't
  NAMESPACE-fail.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit 60f05992ee)
2026-06-24 09:58:17 +02:00
951af764fb fix(#623): close review gaps — 3 chmod 750 /var/log clobbers + tmpfiles defense-in-depth
Review found two gaps the install-d sweep missed:
- chmod-form clobber: soc-gateway/soc-agent/ui-manager did 'chmod 750
  /var/log/secubox' (same #511 traversal class) -> now 0755.
- secubox-core tmpfiles.d only declared /run/secubox; now declares all 5 shared
  parents at 0755 (mode-only, owner-agnostic) for boot/install-time self-heal.
  core 1.1.7 -> 1.1.8.
2026-06-18 10:39:52 +02:00
ebf714f123 fix(core): stop clobbering /var/lib+/usr/share/secubox to 0750 + ship secubox-dirs-guard timer; toolbox: stream_inject default on (closes #630) 2026-06-17 09:33:26 +02:00
CyberMind
f0557d9082
fix(secubox-core): /etc/secubox parent dir 0750 → 0755 (ref #468) (#470)
Non-secubox daemons can't traverse a 0750 secubox:secubox dir even when
the target files are world-readable. Caused secubox-eye-remote-dhcp
(dnsmasq --user=dnsmasq) to fail-loop 625× before manual chmod 0755.

Same constraint will hit hostapd/wpa_supplicant for the upcoming
secubox-mesh radio module (#449), netifyd for secubox-dpi, etc.

/etc/secubox/secrets stays 0700 secubox:secubox — sensitive content
remains private. Opening the parent only exposes file *names*, not
content (CSPN policy preserved).

Live drift already applied on gk2 (2026-06-03). This bumps the source
so the next secubox-core reinstall doesn't regress.

Co-authored-by: CyberMind-FR <gandalf@Gk2.net>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-03 09:11:14 +02:00
055361e574 feat(core): secubox-user-sync — provisioning push of master users into apps (ref #410)
SecuBox stays source of truth. user_store gains set_password() (the single
password write path = capture point) + list_users(); a new host CLI
secubox-user-sync sets the canonical argon2 hash then pushes the same plaintext
(via SECUBOX_USER_PASSWORD env/stdin, never argv) into each app exposing a
`<app>ctl user-provision` verb. nextcloudctl + photoprismctl gain that verb,
each creating a per-user photo folder (/data/shared/photos/<user>) and a
user-scoped library; admin stays unrestricted (management), others scoped.
gk2 + admin are always provisioned (seed). Tests for set_password included.
2026-05-29 07:55:58 +02:00
CyberMind
652bc63707
fix(core): v1.1.5 — lxc.service waits for /data mount before autostart (#374)
Stock lxc.service has After=remote-fs.target but not After=data.mount.
/data is a local ext4 mount (UUID-based, not NFS). At boot lxc.service
ran ~2s in, lxc-autostart enumerated /data/lxc/ before the mount
landed, found nothing, exited 0. Every LXC with lxc.start.auto = 1
stayed STOPPED. Authelia being one of them broke every SSO-gated
vhost — auth_request returned 503, nginx replied HTTP 500.

Fix: systemd drop-in /etc/systemd/system/lxc.service.d/wait-for-data.conf
with RequiresMountsFor=/data. systemd resolves to the right mount unit
and orders lxc.service after it. No-op on appliances without a /data
partition.

Live-deployed on gk2 (1.1.4 → 1.1.5); After= now includes data.mount.

Co-authored-by: CyberMind-FR <gandalf@Gk2.net>
2026-05-23 09:10:35 +02:00
CyberMind
1e90f0d018
fix(secubox-core): v1.1.4 — secubox-runtime defers /run/secubox perms to tmpfiles.d (closes #151) (#321)
The old ExecStart sequence overwrote tmpfiles.d's 1777 root:root with
775 secubox:secubox, killing nginx's ability to traverse the directory
and reach the .sock files inside. Every secubox-*.sock upstream
returned 502 after each reboot. Observed AGAIN on 2026-05-21 after
the MOCHAbin freeze — ~90 services started up but only 8 had usable
sockets, the rest hidden behind broken perms.

New unit:
* Ordered After=systemd-tmpfiles-setup.service so tmpfiles.d wins.
* Re-applies the canonical rule (systemd-tmpfiles --create) as a
  safety net for boards that hit the rule before /run is mounted.
* NO chown / chmod that override tmpfiles.

Co-authored-by: CyberMind-FR <gandalf@Gk2.net>
2026-05-21 16:43:11 +02:00
CyberMind
5b489b183a
fix(secubox-core): v1.1.3 — nftables.service tolerates built-in nf_nat modules (closes nftables half of #150) (#318)
The MOCHAbin custom kernel builds nf_conntrack / nf_nat / nft_chain_nat
as =y not =m, so the stock nftables.service ExecStartPre 'modprobe
nf_nat' exits 1, systemd kills the unit before ExecStart, and the
DNAT/MASQUERADE rules in /etc/nftables.d/*.nft never get loaded —
every reboot lost lyrion slimproto :3483 DNAT, mqtt forwards, etc.

* packages/secubox-core/systemd/nftables.service.d/override.conf (new):
  drop-in that swallows modprobe failures (|| true).
* packages/secubox-core/debian/rules: install the drop-in to
  /etc/systemd/system/nftables.service.d/override.conf.
* Closes the nftables half of #150 (board loses NAT rules at boot).

Co-authored-by: CyberMind-FR <gandalf@Gk2.net>
2026-05-21 13:17:30 +02:00
CyberMind
81238742c2
fix(secubox-core): don't overwrite /etc/nginx/sites-available/secubox on upgrade (closes #162) (#165)
The postinst unconditionally installed `nginx/secubox.conf` (which contains
three server blocks bound to 80/443) over any existing file. On HAProxy-
fronted boards where HAProxy already owns 80/443, this turned the file into
a config bomb: nginx -t still passed (syntax-only), but the next
systemctl restart nginx crashed with `bind() failed (98: Address already
in use)`. The bomb went off during the #156 cookie-audit deploy on the
gk2 prod board (4-min dashboard outage).

Fix:
  - Only install /etc/nginx/sites-available/secubox on first install
    (file absent). Subsequent installs/upgrades keep the operator-tuned
    file intact (same idempotent pattern as the /etc/secubox.conf gate
    a few lines above).
  - Symlink creation already had the same gate (good).
  - nginx-reload now wrapped in nginx -t — don't reload if the merged
    config wouldn't survive a fresh start; print a warning instead.

Operators who customized the file pre-upgrade keep their version. New
installs get the standalone-nginx variant as before.

Changelog bumped to 1.1.2.

Co-authored-by: CyberMind-FR <gandalf@Gk2.net>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 07:52:57 +02:00
a7d17f3d9f chore: post-merge polish for cookie-audit deploy + banner UX (ref #156)
Changelog bumps (built + installed on prod board gk2 during deploy):
  - secubox-core 1.1.0 → 1.1.1 (adds get_cookie_audit_config helper)
  - secubox-metrics 1.0.1 → 1.0.2 (cookie-audit endpoints + aggregator)
  - secubox-hub 1.2.0 → 1.3.0 (health-banner v1.4.x + cookie-inventory.js)

health-banner.js v1.4.0 → v1.4.4 polish:
  - v1.4.1: double-init guard (script loaded twice via index.html
    + nginx sub_filter in webui.conf:33)
  - v1.4.2: sectionContainer() appends inside .hb-content instead of
    #health-banner — fixes latent #92 bug where live sections were
    positioned outside the visible scroll area
  - v1.4.3: remove the 5 module tiles (waf/crowdsec/haproxy/nginx/system)
    — redundant with the persistent indicators top-right
  - v1.4.4: dead-code cleanup (MODULE_EMOJIS, STATUS_EMOJIS, ~40 lines
    of .hb-mod* CSS in both desktop + mobile media query)

WIP.md: cookie-audit section rewritten — pipeline now DEPLOYED on board,
documents the 4 cascade incidents surfaced (issues #162 #163 +
secubox-hub/portal login.html conflict + silent nginx reload no-op) and
the manual workarounds active on the board pending package fixes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 06:46:59 +02:00
bd7dda0c6f feat(secubox): complete meta-script generator Tasks 14-17
Task 14: Arch Profiles
- Add profiles/arch/arm64.yaml and profiles/arch/amd64.yaml
- Add ResolveWithArch() to merger for base → arch → tier chain
- Add tests for arch profile resolution

Task 15: Package secubox.yaml for All Packages
- Add scripts/generate-secubox-yaml.py generator script
- Generate 131 debian/secubox.yaml files with:
  - Category detection (security, network, system, etc.)
  - Tier assignment (all, lite, standard, pro)
  - API socket and UI path detection

Task 16: APT Repository Setup
- Add apt/conf/ reprepro configuration (multi-arch arm64/amd64)
- Add apt/hooks/lintian-check pre-publish validation
- Add scripts/apt-publish.sh and scripts/apt-sync.sh
- Add apt/README.md documentation

Task 17: CI Integration
- Add .github/workflows/build-secubox-cli.yml
- Build for linux-amd64 and linux-arm64
- Version injection via ldflags
- GitHub releases on tag push

Code Quality Fixes (Tasks 10-13):
- Add atomic writes for OTA boot control files (0600 perms)
- Fix NVME device extraction (nvme0n1p2 → nvme0n1)
- Add scanner.Err() checks in hardware detection
- Fix URL injection validation in fetch command
- Add proper cleanup on checksum failures

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-11 05:32:29 +02:00
eb91fe97c7 feat(secubox): add package scanner for debian/secubox.yaml
- Define Component struct with requirements, tags, modes
- Implement Scanner to find all secubox-* packages
- Add SupportsArch() helper method
- Create secubox-core/debian/secubox.yaml example

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-10 20:46:57 +02:00
26f5fb945c fix(boot): Use correct initrd for LED kernel entry (ref #39)
- extlinux.conf: secubox-led entry now uses initrd.img-6.12.85
  (matches kernel 6.12.85, not the +deb12-arm64 variant)
- This fixes "Driver 'mv64xxx_i2c' is already registered" error
  caused by kernel/initrd module mismatch
- Add secubox-led-k2000 script for rainbow LED effect

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-07 07:38:53 +02:00
85defaa461 feat(secubox-core): Integrate LED heartbeat into core package (ref #39)
- Add /usr/sbin/secubox-led-heartbeat script
- Add secubox-led-heartbeat.service systemd unit
- Update debian/rules to install heartbeat components
- Add README.md with documentation

LED heartbeat uses IS31FL3199 via sysfs with I2C timing delays.
Configurable via LED_COLOR and LED_NUM environment variables.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-07 07:15:11 +02:00
fa058841c9 feat(cli): SecuBox CLI v2.0.0 with security commands
- Add threats, waf, firewall, bans, vhosts, certs commands
- Add mode switcher (kiosk/tui/console)
- Add acme-renew command for SSL certificate renewal
- Fix README license reference (Apache-2.0 → CMSD-1.0)
- Update WIP.md for Session 104

Addresses OPORD findings F-001 (SSL renewed) and F-002 (license fixed)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-06 13:14:01 +02:00
a697925a3f fix(build): Upgrade Python deps + CORS + login endpoint fixes
- Add CORS headers to nginx secubox-proxy.conf for cross-origin API requests
- Fix login.html endpoints: /auth/login -> /login
- Upgrade Python deps in build scripts: pydantic>=2.0, fastapi>=0.100, uvicorn>=0.25
- Add pip upgrade in secubox-core postinst for Debian bookworm compatibility
- Fix display/__init__.py to import existing modules only

Fixes authentication and API issues in VBox and ebin builds.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-28 20:53:40 +02:00
de77a1aa4e feat(build): Add modular build system and fix package dependencies
Build System:
- Add image/lib/common.sh with shared build functions
- Add profiles for vm-x64, x64-live, rpi400, espressobin-v7
- Add BUILD-SYSTEM.md documentation
- Add splash screens (boot.png, tui-splash.sh, kiosk-loading.sh)
- Add Plymouth theme for boot splash

Package Dependencies:
- Fix python3-uvicorn -> python3-uvicorn | python3-pip
- Fix python3-fastapi -> python3-fastapi | python3-pip
- Fix python3-httpx -> python3-httpx | python3-pip
- Allows packages to install when pip-provided deps are used

Documentation:
- Add Build-System.md wiki page
- Update _Sidebar.md with build system links
- Add VM-Testing.md improvements

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-10 17:31:24 +02:00
33d287c563 fix: Disable PXE boot on VirtualBox NICs
Add --nicbootprio1 0 and --nicbootprio2 0 to prevent VirtualBox
from attempting network boot when hard disk boot fails.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-08 19:08:56 +02:00
6a0b9f45a1 feat: Add secubox CLI tool
Provides common commands:
- secubox status - system and services overview
- secubox services - list all SecuBox services
- secubox logs [svc] - view service logs
- secubox restart/start/stop <svc> - manage services
- secubox info - system information
- secubox network - network configuration
- secubox version - version info

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-07 06:54:25 +02:00
8d5e71f98b fix(core): Set /run/secubox world-writable for service sockets
- Add tmpfiles.d/secubox.conf with mode 1777 (sticky + world-writable)
- Update postinst to create /run/secubox with correct permissions
- Run systemd-tmpfiles --create on package install

This fixes permission denied errors when services try to create
Unix sockets in /run/secubox directory.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-04 08:14:51 +02:00
d3e9352722 feat(core): Add board detection and kiosk management library
- secubox_core v1.1.0: New kiosk.py module with reusable functions
  - Board detection (MOCHAbin, ESPRESSObin, x64-vm, x64-baremetal, RPi)
  - Interface classification (WAN/LAN/SFP by board type)
  - Kiosk management (status, enable, disable)
- secubox-system v1.2.0: Board Detection and Kiosk cards in UI
  - Uses secubox_core.kiosk (no code duplication)
  - New endpoints: /board, /board/detect, /board/capabilities, /kiosk/*
- secubox-hub v1.1.0: Network Mode selection on dashboard
  - Mode selector with preview and apply
  - Proxies to secubox-netmodes via Unix socket
  - New endpoints: /network_mode, /network_mode/preview, /board_summary
- secubox-portal v2.1.0: Device-specific theming
  - 7 board themes (Pro, Lite, Virtual, Server, Maker, Standard)
  - Login page dynamically adapts colors and badge
  - New endpoints: /theme, /branding

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-01 05:52:19 +02:00
ba6b5da03f Add secubox-runtime.service to ensure /run/secubox exists
This systemd service runs before all secubox services to create
the /run/secubox directory with correct ownership and permissions.
Fixes recurring issue where socket directory disappears causing
502 Bad Gateway errors and navbar showing only 2 categories.

- New oneshot service: secubox-runtime.service
- Runs before secubox-hub, secubox-portal, secubox-p2p
- Creates /run/secubox owned by secubox:secubox with mode 775
- Updated debian/rules to install the service
- Updated debian/postinst to enable the service

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-26 15:57:38 +01:00
1868fa2d8c feat(mail): Debian LXC containers for Postfix/Dovecot/Roundcube
Mail Server LXC (mailserverctl v2.1.0):
- Switch from Alpine to Debian bookworm via debootstrap
- Host networking (lxc.net.0.type = none)
- Postfix + Dovecot with virtual mailbox support
- User management via mailctl (add/list/remove)
- DKIM key generation

Roundcube Webmail LXC (roundcubectl v1.4.0):
- Debian bookworm with roundcube package
- SQLite backend, port 8027
- PHP-FPM 8.2 + nginx
- Three-fold commands (components, access)

Also includes:
- Three-fold architecture for 6 modules
- Maintainer update to Gerald KERMA
- Authentication fixes (JWT secret, redirect paths)
- 4 new modules (c3box, gitea, nextcloud, portal)
- WIP.md updated with session progress

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-22 10:40:00 +01:00
7c42a80baf feat: modular nginx config + hub roadmap + new modules
Nginx architecture:
- Modular config: each module installs /etc/nginx/secubox.d/<module>.conf
- Auto-register on install, auto-remove on purge
- Main config includes from secubox.d/*.conf
- 27 module snippets for dynamic component management

Hub enhancements:
- Add roadmap widget showing migration progress (84% complete)
- Add /api/v1/hub/roadmap endpoint with category breakdown
- Shared sidebar.css for consistent styling across modules

New modules:
- secubox-portal: JWT authentication, session management
- secubox-dns: DNS server management
- secubox-mail: Mail server (Postfix) management
- secubox-webmail: Roundcube webmail
- secubox-users: User account management
- secubox-publish: Content publishing
- secubox-waf: Web Application Firewall
- secubox-mail-lxc: Mail LXC container
- secubox-webmail-lxc: Webmail LXC container

Debian packaging:
- All modules updated with modular nginx support
- postinst: creates secubox.d/, reloads nginx
- prerm: removes snippet, reloads nginx
- rules: installs nginx/<module>.conf

Scripts:
- new-package.sh: generates modular nginx files for new modules
- retrofit-nginx-modular.sh: updates existing packages

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-21 20:34:01 +01:00
065560326d fix: complete CSS variables and add module scaffold skill
- Add missing --cyan, --yellow, --purple CSS vars to metablogizer,
  streamlit, streamforge, haproxy, vhost frontends
- Create /module skill for scaffolding new SecuBox modules
- Add new-module.sh script with complete package template
- Clean up debian build artifacts from git
- Update .gitignore for debian build dirs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-21 18:27:21 +01:00
bf1babb37c Initial commit: SecuBox-DEB migration from OpenWrt to Debian
Includes all package APIs with public dashboard endpoints:
- secubox-system: System Hub with /info, /resources, /security
- secubox-crowdsec: CrowdSec dashboard with /status, /hub, /metrics, actions
- secubox-wireguard: WireGuard VPN with /interfaces, /peers, start/stop
- secubox-netdata: Monitoring with /stats, /processes, /alerts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-21 09:41:06 +01:00