ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
fleet_path_authority.py
Go to the documentation of this file.
1# SPDX-License-Identifier: MIT
2# Copyright (c) 2026 Brighton Sikarskie
3"""Authenticate executable and plugin trees before fleet control-plane use."""
4
5from __future__ import annotations
6
7from pathlib import Path
8
9
10def confined_link_errors(root: Path) -> list[str]:
11 """Return every broken, absolute, or escaping symlink below ``root``."""
12 try:
13 authority = root.resolve(strict=True)
14 except OSError as exc:
15 return [f"collection tree is unavailable: {exc}"]
16 if root.absolute() != authority or root.is_symlink() or not root.is_dir():
17 return ["collection tree root is not a real owned directory"]
18 errors: list[str] = []
19 for entry in sorted(root.rglob("*")):
20 try:
21 entry.lstat()
22 except OSError as exc:
23 errors.append(f"cannot lstat {entry}: {exc}")
24 continue
25 if not entry.is_symlink():
26 continue
27 target_text = entry.readlink()
28 try:
29 target = entry.resolve(strict=True)
30 except (OSError, RuntimeError) as exc:
31 errors.append(f"broken collection link {entry}: {exc}")
32 continue
33 if target_text.is_absolute() or not target.is_relative_to(authority):
34 errors.append(f"collection link escapes its root: {entry}")
35 if not (target.is_file() or target.is_dir()):
36 errors.append(f"collection link target is not a file or directory: {entry}")
37 return errors