diff --git a/.github/workflows/license-check.yml b/.github/workflows/license-check.yml new file mode 100644 index 0000000..4125814 --- /dev/null +++ b/.github/workflows/license-check.yml @@ -0,0 +1,32 @@ +name: license-check + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + license-artifacts: + name: License & provenance artifact check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Install build dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential busybox-static python3 tar xz-utils curl + + - name: Build base packages + run: make packages + + - name: Check ELF artifacts against the license allowlist + run: | + python3 scripts/check-license-artifacts.py \ + --root packages \ + --root distro/packages \ + --allowlist licenses/allowlist.json diff --git a/RELEASE-NOTES-v1.2.0.md b/RELEASE-NOTES-v1.2.0.md index a033ba0..985aab4 100644 --- a/RELEASE-NOTES-v1.2.0.md +++ b/RELEASE-NOTES-v1.2.0.md @@ -1,5 +1,10 @@ # S.A.N.E Linux v1.2.0 Release Notes +> **Document status (2026-11-30):** This file preserves the original v1.2.0 +> release notes. The licensing, provenance, source-availability, and +> license-check work added after that release is recorded in the addendum in +> section 6. For the current source offer, see [`SOURCE-OFFER.md`](SOURCE-OFFER.md). + ## 1. Overview S.A.N.E Linux v1.2.0 is a major milestone release delivering production-grade init lifecycle control, fail-closed privilege drop semantics, a full POSIX-compliant package manager (`spm`) with atomic transactions and hardened archive validation, guest offline installer support for BIOS and UEFI GPT systems, immutable upstream kernel toolchain pinning, and root-owned deterministic initramfs generation. @@ -70,3 +75,34 @@ S.A.N.E Linux v1.2.0 is a major milestone release delivering production-grade in - **Guidance for Package Authors & System Deployers**: - Kernel and bootloader installation scripts must perform staging and copy operations within the same filesystem or explicitly handle cross-device copying when updating `/boot`. - Never attempt to symlink `/boot/vmlinuz` to a versioned kernel binary on a FAT32 ESP partition. + +--- + +## 6. Addendum 2026-11-30 — Licensing, provenance & source availability + +This addendum records the follow-up licensing work that landed after the +original v1.2.0 release. It does not change the historical feature list above. + +- Full license texts are bundled under `licenses/`, with provenance recorded in + `licenses/README.md`. +- `SOURCE-OFFER.md` carries the written offer for complete corresponding + source, valid for at least three years after the last distribution of the + covered binaries. +- The permanent source release is `v1.2.1-source`: + . It + contains the kernel bundle, both BusyBox source variants, the dosfstools + source package, and the pinned `build-rootfs-1.36.1.sh` script. +- `packages/kernel/PROVENANCE` and `packages/disk-tools/PROVENANCE` record the + exact upstreams, hashes, and build paths of the shipped kernel and + dosfstools binaries. +- A canonical `packages/busybox/config-1.36.1` is committed and consumed by + `scripts/build-rootfs.sh`. +- A new license-check workflow, `.github/workflows/license-check.yml`, runs + `scripts/check-license-artifacts.py` against `packages/` and the built + `distro/packages/` output, using `licenses/allowlist.json`. Unknown ELF + binaries or hash mismatches now fail the build instead of slipping through + unnoticed. +- Phase 4 (history rewrite with `git filter-repo`) is deliberately **not** + executed. It is recorded as an archive note only, because source offers and + release assets already satisfy the GPL obligations without rewriting public + history. diff --git a/archive/2026-11-30-phase4-history-rewrite-note.md b/archive/2026-11-30-phase4-history-rewrite-note.md new file mode 100644 index 0000000..81dea41 --- /dev/null +++ b/archive/2026-11-30-phase4-history-rewrite-note.md @@ -0,0 +1,27 @@ +# Phase 4 archive note — history rewrite decision + +Date: 2026-11-30. + +The earlier suggestion was to run `git filter-repo` to remove BusyBox and +kernel binaries from all history, followed by force-push of all branches and +tags. + +Decision: **do not execute that rewrite.** This file is the only record of +that decision. + +Reasons: + +- The complete corresponding sources are already published in the permanent + `v1.2.1-source` GitHub Release, so the GPL obligations do not depend on + deleting historical binaries. +- Rewriting published history would invalidate PR heads, release tags, and + existing forks/clones, and would require regenerating release assets and + tags. +- Force-pushing all branches and tags is a destructive operation that should + never be performed as a reflex to a license audit. +- Keeping this note preserves the rationale without pretending the rewrite was + ever carried out. + +If a future maintainer still wants to shrink history, it must be a separate, +explicitly approved migration after the source releases are final and a full +backup exists. This note does not authorize that operation. diff --git a/licenses/README.md b/licenses/README.md index db913b5..96e099e 100644 --- a/licenses/README.md +++ b/licenses/README.md @@ -23,3 +23,18 @@ above are recorded for verification. For the GPL-2.0-only binaries shipped in S.A.N.E Linux images, see [`SOURCE-OFFER.md`](../SOURCE-OFFER.md) and [`THIRD_PARTY_LICENSES.md`](../THIRD_PARTY_LICENSES.md). + +## License artifact allowlist + +`allowlist.json` is consumed by `scripts/check-license-artifacts.py` and by the +`license-check` GitHub Actions workflow. Each entry names a binary path or +glob, its license, and its source reference. First-party packages are marked +with `first_party: true` so they are not mistaken for third-party GPL payloads. +`*` and `?` in globs do not cross `/`; use `**` for recursive matching. +Unreadable files or directories fail the gate rather than being skipped. +Optional `sha256` fields pin critical binaries (BusyBox, kernel, dosfstools); +when present they are checked for every matched regular file. Applet symlinks +are skipped because they are aliases, not independent payloads; a new regular +ELF still fails unless it is registered here. When adding a new binary, update +this file and `THIRD_PARTY_LICENSES.md` in the same PR, and publish its source +asset if it is third-party. diff --git a/licenses/allowlist.json b/licenses/allowlist.json new file mode 100644 index 0000000..0b4252e --- /dev/null +++ b/licenses/allowlist.json @@ -0,0 +1,112 @@ +[ + { + "path": "packages/ninit/x/sbin/init", + "component": "ninit", + "license": "MIT", + "source_ref": "ninit.c and scripts/ in this repository", + "first_party": true + }, + { + "path": "packages/busybox/x/**", + "match": "glob", + "component": "BusyBox (Ubuntu build)", + "license": "GPL-2.0-only", + "source_ref": "busybox-ubuntu-1.37.0-7ubuntu1-source.tar.gz in v1.2.1-source", + "sha256": "8d4e5a13ce30fb66fa7156a25f738e690b1dfc4823774dfab5a0f1fd7fed48f7" + }, + { + "path": "packages/kernel/x/boot/vmlinuz-virt", + "component": "Linux kernel 6.6.134 virt flavor", + "license": "GPL-2.0-only", + "source_ref": "linux-6.6.134-sane-source.tar.gz in v1.2.1-source", + "sha256": "be523954ad673a78c9cdfd3d473a8d39609f5901adfcc68402c67dc037a64c7e" + }, + { + "path": "packages/kernel/x/lib/modules/**/*.ko", + "match": "glob", + "component": "Linux kernel modules 6.6.134", + "license": "GPL-2.0-only", + "source_ref": "linux-6.6.134-sane-source.tar.gz in v1.2.1-source" + }, + { + "path": "packages/disk-tools/x/usr/sbin/mkfs.fat", + "component": "dosfstools", + "license": "GPL-3.0-only", + "source_ref": "dosfstools-ubuntu-4.2-1.2build1-source.tar.gz in v1.2.1-source", + "sha256": "3bded05c428857023571416308f0ecf0fce2f9d44f0e5b7ec3b371c1350f45a4" + }, + { + "path": "packages/disk-tools/x/usr/sbin/sgdisk", + "component": "gptfdisk", + "license": "GPL-2.0-only", + "source_ref": "https://sourceforge.net/projects/gptfdisk/" + }, + { + "path": "packages/disk-tools/x/usr/sbin/mke2fs", + "component": "e2fsprogs", + "license": "GPL-2.0-only", + "source_ref": "https://e2fsprogs.sourceforge.net/" + }, + { + "path": "packages/curl/x/usr/bin/curl", + "component": "curl", + "license": "curl license (MIT/X derivative)", + "source_ref": "licenses/curl.txt and curl 8.11.0 upstream" + }, + { + "path": "packages/doas/x/usr/bin/doas", + "component": "OpenDoas", + "license": "ISC", + "source_ref": "https://github.com/Duncaen/OpenDoas/releases/download/v6.8.2/opendoas-6.8.2.tar.gz" + }, + { + "path": "packages/libressl/x/usr/bin/openssl", + "component": "LibreSSL", + "license": "ISC (includes OpenSSL-derived code)", + "source_ref": "https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.9.2.tar.gz" + }, + { + "path": "packages/libressl/x/usr/bin/ocspcheck", + "component": "LibreSSL", + "license": "ISC (includes OpenSSL-derived code)", + "source_ref": "https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.9.2.tar.gz" + }, + { + "path": "packages/limine-static/x/usr/bin/limine", + "component": "Limine bootloader", + "license": "BSD-2-Clause", + "source_ref": "https://github.com/Limine-Bootloader/Limine/releases/download/v12.9.6/limine-binary.tar.xz" + }, + { + "path": "packages/wpa-supplicant/x/usr/bin/wpa_supplicant", + "component": "wpa_supplicant", + "license": "BSD-3-Clause (GPL-2.0 alternative)", + "source_ref": "https://w1.fi/releases/wpa_supplicant-2.10.tar.gz" + }, + { + "path": "packages/wpa-supplicant/x/usr/bin/wpa_cli", + "component": "wpa_supplicant", + "license": "BSD-3-Clause (GPL-2.0 alternative)", + "source_ref": "https://w1.fi/releases/wpa_supplicant-2.10.tar.gz" + }, + { + "path": "packages/musl/x/usr/lib/libc.so", + "component": "musl libc", + "license": "MIT", + "source_ref": "https://musl.libc.org/releases/musl-1.2.5.tar.gz" + }, + { + "path": "packages/musl/x/lib/ld-musl-*.so.*", + "match": "glob", + "component": "musl libc dynamic loader", + "license": "MIT", + "source_ref": "https://musl.libc.org/releases/musl-1.2.5.tar.gz" + }, + { + "path": "packages/musl/x/usr/lib/*.o", + "match": "glob", + "component": "musl libc startup objects", + "license": "MIT", + "source_ref": "https://musl.libc.org/releases/musl-1.2.5.tar.gz" + } +] diff --git a/scripts/check-license-artifacts.py b/scripts/check-license-artifacts.py new file mode 100644 index 0000000..9b916f2 --- /dev/null +++ b/scripts/check-license-artifacts.py @@ -0,0 +1,230 @@ +#!/usr/bin/env python3 +"""Fail if an ELF binary in a build/output tree is not registered in allowlist. + +Stdlib only. The allowlist is a JSON list of entries: + {"path": "packages/busybox/x/bin/busybox", "component": "BusyBox", + "license": "GPL-2.0-only", "source_ref": "busybox-ubuntu-...tar.gz", + "sha256": "optional", "match": "exact|glob"} + +- `match: exact` compares the repo-relative path exactly. +- `match: glob` uses POSIX-like globbing: `*` and `?` do not cross `/`; + `**` matches any number of path segments, including none. +- `sha256` is optional; when present every matched ELF file is checked, and + exact pinned entries are also checked when the payload is not ELF (vmlinuz). +- Symlinks are skipped because applet symlinks are not independent payloads; + a new regular ELF still fails unless it is registered here. +- `first_party: true` marks entries whose source is this repository itself. +""" +from __future__ import annotations + +import argparse +import hashlib +import json +import os +import re +import sys +from pathlib import Path + + +def sha256_of(path: Path) -> str: + h = hashlib.sha256() + with path.open("rb") as f: + for chunk in iter(lambda: f.read(1024 * 1024), b""): + h.update(chunk) + return h.hexdigest() + + +def iter_elf_files(root: Path, on_error=None): + """Yield (path, error). Unreadable candidates and directories are reported.""" + for dirpath, dirnames, filenames in os.walk(root, onerror=on_error, + followlinks=False): + dirnames.sort() + filenames.sort() + for name in filenames: + p = Path(dirpath) / name + if p.is_symlink() or not p.is_file(): + continue + try: + with p.open("rb") as f: + magic = f.read(4) + except OSError as exc: + yield p, f"cannot read: {exc}" + continue + if magic == b"\x7fELF": + yield p, None + + +def glob_to_regex(pattern: str) -> re.Pattern[str]: + """Translate the allowlist glob dialect into an anchored regex.""" + out = ["^"] + i = 0 + while i < len(pattern): + char = pattern[i] + if char == "*": + if i + 1 < len(pattern) and pattern[i + 1] == "*": + i += 2 + if i < len(pattern) and pattern[i] == "/": + out.append("(?:.*/)?") + i += 1 + else: + out.append(".*") + else: + out.append("[^/]*") + i += 1 + elif char == "?": + out.append("[^/]") + i += 1 + else: + out.append(re.escape(char)) + i += 1 + out.append("$") + return re.compile("".join(out)) + + +def matches(path: str, entry: dict, cache: dict[str, re.Pattern[str]]) -> bool: + pattern = entry["path"] + if entry.get("match", "exact") == "glob": + regex = cache.get(pattern) + if regex is None: + regex = glob_to_regex(pattern) + cache[pattern] = regex + return bool(regex.match(path)) + return path == pattern + + +def load_allowlist(path: Path) -> list[dict]: + try: + data = json.loads(path.read_text()) + except OSError as exc: + print(f"FAIL: cannot read allowlist {path}: {exc}", file=sys.stderr) + raise SystemExit(1) + except json.JSONDecodeError as exc: + print(f"FAIL: invalid JSON in allowlist {path}: {exc}", file=sys.stderr) + raise SystemExit(1) + + if not isinstance(data, list): + print(f"FAIL: allowlist {path} must contain a JSON list", file=sys.stderr) + raise SystemExit(1) + + for index, entry in enumerate(data): + if not isinstance(entry, dict) or not isinstance(entry.get("path"), str): + print(f"FAIL: allowlist entry {index} is missing a string path", file=sys.stderr) + raise SystemExit(1) + for field in ("license", "source_ref"): + value = entry.get(field) + if not isinstance(value, str) or not value.strip(): + print(f"FAIL: allowlist entry {index} is missing a non-empty {field}", + file=sys.stderr) + raise SystemExit(1) + if entry.get("match", "exact") not in ("exact", "glob"): + print(f"FAIL: allowlist entry {index} has an invalid match mode", file=sys.stderr) + raise SystemExit(1) + digest = entry.get("sha256") + if digest is not None and not re.fullmatch(r"[0-9a-f]{64}", digest): + print(f"FAIL: allowlist entry {index} has an invalid sha256", file=sys.stderr) + raise SystemExit(1) + return data + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--root", action="append", required=True, + help="Directory to scan; may be repeated.") + ap.add_argument("--allowlist", default="licenses/allowlist.json") + ap.add_argument("--repo-root", default=".", + help="Base for relative paths; defaults to the current directory.") + args = ap.parse_args() + + base = Path(args.repo_root).resolve() + allowlist_path = Path(args.allowlist) + if not allowlist_path.is_absolute(): + allowlist_path = base / allowlist_path + entries = load_allowlist(allowlist_path) + + cache: dict[str, re.Pattern[str]] = {} + failures: list[tuple[str, str]] = [] + checked = 0 + scanned: set[str] = set() + + def on_scan_error(exc: OSError) -> None: + filename = getattr(exc, "filename", None) + failures.append((str(filename) if filename else "scan root", + f"cannot scan: {exc}")) + + for root_arg in args.root: + root = Path(root_arg) + if not root.is_absolute(): + root = base / root + if not root.exists(): + failures.append((root_arg, "scan root does not exist")) + continue + for elf, error in iter_elf_files(root, on_scan_error): + try: + rel = elf.relative_to(base).as_posix() + except ValueError: + rel = elf.as_posix() + if error: + failures.append((rel, error)) + continue + scanned.add(rel) + checked += 1 + matching = [entry for entry in entries if matches(rel, entry, cache)] + if not matching: + failures.append((rel, "not registered in licenses/allowlist.json")) + continue + for entry in matching: + expected = entry.get("sha256") + if not expected: + continue + try: + actual = sha256_of(elf) + except OSError as exc: + failures.append((rel, f"cannot hash: {exc}")) + continue + if actual != expected: + failures.append( + (rel, + f"sha256 mismatch: expected {expected}, got {actual}. " + "Update the allowlist and its source asset in the same PR.")) + + # Pinned exact entries are checked even when the payload is not ELF, e.g. + # vmlinuz. Glob entries were already checked for every ELF they matched. + for entry in entries: + expected = entry.get("sha256") + if not expected or entry.get("match", "exact") == "glob": + continue + rel = entry["path"] + if rel in scanned: + continue + path = base / rel + if not path.exists(): + failures.append((rel, "expected binary is missing")) + continue + if path.is_symlink(): + failures.append((rel, "pinned artifact must be a regular file")) + continue + try: + actual = sha256_of(path) + except OSError as exc: + failures.append((rel, f"cannot hash: {exc}")) + continue + if actual != expected: + failures.append( + (rel, + f"sha256 mismatch: expected {expected}, got {actual}. " + "Update the allowlist and its source asset in the same PR.")) + + if failures: + print(f"FAIL: {len(failures)} unlicensed or mismatched artifact(s)") + for rel, why in failures: + print(f" - {rel}: {why}") + print("Add the artifact to licenses/allowlist.json and to " + "THIRD_PARTY_LICENSES.md (plus its source asset if third-party).") + return 1 + + print(f"PASS: {checked} ELF artifact(s) registered in licenses/allowlist.json") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())