Encrypted image setups can now bake a Tor onion service into the initramfs so the dropbear unlock shell stays reachable behind NAT or a dynamic IP. When the user opts in, configure_encryption installs tor + busybox, drops the mkinitcpio hooks (ordered `netconf tor dropbear encryptssh`), generates the v3 onion keys offline in the image chroot, and prints the stable .onion address. Unlock with `torsocks ssh root@<onion-address>`. The runtime hook syncs the clock via NTP first (RTC-less boards boot at 1970, which Tor's consensus checks reject) and starts the onion service pointing at dropbear on 127.0.0.1:22. Hardening baked in from an adversarial review of the shipped path: - cmdline.txt boot path (RPi4-class firmware boot) now sets the same ip=::::<host>:eth0:dhcp net.ifnames=0 params as the boot.txt path, so the initramfs actually gets a network and the onion can publish. - the initramfs bakes in libnss_dns.so.2 so the NTP hostname resolves. - the hook extracts DHCP DNS with sed instead of sourcing the lease files, which would run attacker-controlled DHCP option strings as root pre-boot. - NTP is attempted unconditionally (bounded), not gated on DHCP-provided DNS. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
33 lines
937 B
Python
33 lines
937 B
Python
"""The image setup plan collected from the user's answers."""
|
|
|
|
from dataclasses import dataclass, field
|
|
from pathlib import Path
|
|
|
|
DEFAULT_BOOT_SIZE = "+500M"
|
|
|
|
|
|
@dataclass
|
|
class ImagePlan:
|
|
operation_system: str = "linux"
|
|
distribution: str | None = None
|
|
base_download_url: str | None = None
|
|
image_name: str | None = None
|
|
image_checksum: str | None = None
|
|
boot_size: str = ""
|
|
luks_memory_cost: str | None = None
|
|
raspberry_pi_version: str | None = None
|
|
encrypt_system: bool = False
|
|
tor_unlock: bool = False
|
|
root_filesystem: str = ""
|
|
image_folder: Path = field(default_factory=Path)
|
|
|
|
@property
|
|
def download_url(self) -> str | None:
|
|
if self.base_download_url is None or self.image_name is None:
|
|
return None
|
|
return f"{self.base_download_url}{self.image_name}"
|
|
|
|
@property
|
|
def image_path(self) -> Path:
|
|
return self.image_folder / self.image_name
|