Split the mkinitcpio-only remote-LUKS-unlock path into an InitramfsBackend ABC with a get_backend() dispatch, and add the initramfs-tools backend for Debian / Raspberry Pi OS. - base.py: six-step backend contract; encryption.py becomes a thin, distro-neutral sequencer (get_backend by distribution). - initramfs_tools.py: crypttab `none luks,initramfs`, cmdline rewritten to root=/dev/mapper + ip=::::host:eth0:dhcp, dropbear-initramfs authorized_keys, update-initramfs -k all (no build-host uname leak). - shipped hooks (configuration/initramfs-tools/*): single-hop non-anonymous onion, libnss DNS baking, sed-not-source DHCP, kill-tor-before-pivot. - shared offline onion keygen in keygen.py; tor.py removed (logic moved to mkinitcpio.py). - raspios added to the apt distro family (session.py, raspberry.py). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
"""The initramfs backend interface.
|
|
|
|
Encrypted remote-unlock images differ by init system: Arch/Manjaro use
|
|
mkinitcpio, Debian/Raspberry Pi OS use initramfs-tools. Each backend owns the
|
|
distro-specific bits (package set, crypttab syntax, initramfs generation,
|
|
bootloader cmdline, and how the Tor hook is baked in); the encryption flow
|
|
orchestrates them the same way for every distro.
|
|
"""
|
|
|
|
from abc import ABC, abstractmethod
|
|
from pathlib import Path
|
|
|
|
from lim.image.plan import ImagePlan
|
|
from lim.image.session import ImageSession
|
|
|
|
|
|
class InitramfsBackend(ABC):
|
|
"""Distro-specific steps to build an encrypted, remote-unlockable image."""
|
|
|
|
@abstractmethod
|
|
def luks_package_collection(self) -> str:
|
|
"""Name of the package collection providing the LUKS/unlock stack."""
|
|
|
|
@abstractmethod
|
|
def install_authorized_key(self, root: Path, authorized_keys: Path) -> None:
|
|
"""Place the SSH public key where the initramfs dropbear reads it."""
|
|
|
|
@abstractmethod
|
|
def install_tor_unlock(self, plan: ImagePlan, root: Path) -> str:
|
|
"""Bake the Tor onion service into the initramfs; return the address."""
|
|
|
|
@abstractmethod
|
|
def register_encrypted_root(self, plan: ImagePlan, session: ImageSession, root: Path) -> None:
|
|
"""Write fstab and crypttab in the distro's syntax."""
|
|
|
|
@abstractmethod
|
|
def configure_initramfs(self, plan: ImagePlan, root: Path) -> None:
|
|
"""Configure the initramfs modules/hooks and (re)generate it."""
|
|
|
|
@abstractmethod
|
|
def configure_bootloader(self, plan: ImagePlan, session: ImageSession, root: Path) -> None:
|
|
"""Point the bootloader at the encrypted root with early networking."""
|