linux-image-manager 2.4.0__tar.gz → 3.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. {linux_image_manager-2.4.0/linux_image_manager.egg-info → linux_image_manager-3.0.0}/PKG-INFO +29 -15
  2. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/README.md +28 -14
  3. linux_image_manager-3.0.0/lim/__init__.py +1 -0
  4. linux_image_manager-3.0.0/lim/catalog.py +80 -0
  5. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/cli.py +5 -7
  6. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/config.py +1 -6
  7. linux_image_manager-3.0.0/lim/configuration/chroot/login-user.sh +28 -0
  8. linux_image_manager-3.0.0/lim/configuration/chroot/onion-keygen.sh +19 -0
  9. linux_image_manager-2.4.0/lim/configuration/initcpio/tor_hook → linux_image_manager-3.0.0/lim/configuration/initcpio/hook +0 -13
  10. linux_image_manager-2.4.0/lim/configuration/initcpio/tor_install → linux_image_manager-3.0.0/lim/configuration/initcpio/install +0 -9
  11. linux_image_manager-3.0.0/lim/configuration/initramfs-tools/bottom +16 -0
  12. linux_image_manager-2.4.0/lim/configuration/initramfs-tools/tor_hook → linux_image_manager-3.0.0/lim/configuration/initramfs-tools/hook +1 -8
  13. linux_image_manager-2.4.0/lim/configuration/initramfs-tools/tor_premount → linux_image_manager-3.0.0/lim/configuration/initramfs-tools/premount +8 -15
  14. {linux_image_manager-2.4.0/lim → linux_image_manager-3.0.0/lim/core}/device.py +5 -15
  15. linux_image_manager-3.0.0/lim/core/errors.py +2 -0
  16. {linux_image_manager-2.4.0/lim → linux_image_manager-3.0.0/lim/core}/fsutil.py +12 -11
  17. {linux_image_manager-2.4.0/lim → linux_image_manager-3.0.0/lim/core}/luks.py +7 -9
  18. {linux_image_manager-2.4.0/lim → linux_image_manager-3.0.0/lim/core}/runner.py +44 -43
  19. {linux_image_manager-2.4.0/lim → linux_image_manager-3.0.0/lim/core}/system.py +4 -8
  20. {linux_image_manager-2.4.0/lim → linux_image_manager-3.0.0/lim/core}/ui.py +6 -2
  21. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/data/crypt.py +2 -3
  22. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/data/sync.py +31 -14
  23. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/distributions.yml +16 -15
  24. linux_image_manager-3.0.0/lim/image/acquire/__init__.py +0 -0
  25. linux_image_manager-3.0.0/lim/image/acquire/cache.py +20 -0
  26. {linux_image_manager-2.4.0/lim/image → linux_image_manager-3.0.0/lim/image/acquire}/choosers.py +14 -11
  27. {linux_image_manager-2.4.0/lim/image → linux_image_manager-3.0.0/lim/image/acquire}/loopimg.py +2 -6
  28. linux_image_manager-3.0.0/lim/image/acquire/retroflag.py +38 -0
  29. {linux_image_manager-2.4.0/lim/image → linux_image_manager-3.0.0/lim/image/acquire}/transfer.py +39 -36
  30. linux_image_manager-3.0.0/lim/image/acquire/verify.py +173 -0
  31. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/image/backup.py +3 -4
  32. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/image/chroot.py +2 -4
  33. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/image/crossarch.py +2 -12
  34. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/image/initramfs/__init__.py +1 -4
  35. linux_image_manager-3.0.0/lim/image/initramfs/base.py +42 -0
  36. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/image/initramfs/initramfs_tools.py +29 -48
  37. linux_image_manager-3.0.0/lim/image/initramfs/keygen.py +25 -0
  38. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/image/initramfs/mkinitcpio.py +23 -32
  39. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/image/plan.py +3 -5
  40. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/image/raspberry.py +64 -46
  41. linux_image_manager-3.0.0/lim/image/security/__init__.py +0 -0
  42. linux_image_manager-3.0.0/lim/image/security/encryption.py +68 -0
  43. {linux_image_manager-2.4.0/lim/image → linux_image_manager-3.0.0/lim/image/security}/hostkeys.py +6 -10
  44. {linux_image_manager-2.4.0/lim/image → linux_image_manager-3.0.0/lim/image/security}/unlock.py +15 -16
  45. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/image/session.py +59 -53
  46. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/image/setup.py +13 -40
  47. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/image/wizard.py +46 -68
  48. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/packages.py +1 -4
  49. linux_image_manager-3.0.0/lim/pins.yml +30 -0
  50. linux_image_manager-3.0.0/lim/storage/__init__.py +0 -0
  51. linux_image_manager-3.0.0/lim/storage/common.py +57 -0
  52. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/storage/raid1.py +17 -11
  53. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/storage/single_drive.py +11 -17
  54. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0/linux_image_manager.egg-info}/PKG-INFO +29 -15
  55. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/linux_image_manager.egg-info/SOURCES.txt +27 -19
  56. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/pyproject.toml +8 -2
  57. linux_image_manager-2.4.0/lim/__init__.py +0 -3
  58. linux_image_manager-2.4.0/lim/catalog.py +0 -35
  59. linux_image_manager-2.4.0/lim/configuration/initramfs-tools/tor_bottom +0 -19
  60. linux_image_manager-2.4.0/lim/errors.py +0 -2
  61. linux_image_manager-2.4.0/lim/image/encryption.py +0 -42
  62. linux_image_manager-2.4.0/lim/image/initramfs/base.py +0 -46
  63. linux_image_manager-2.4.0/lim/image/initramfs/keygen.py +0 -54
  64. linux_image_manager-2.4.0/lim/image/verify.py +0 -98
  65. linux_image_manager-2.4.0/lim/storage/common.py +0 -38
  66. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/LICENSE.txt +0 -0
  67. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/configuration/initcpio/torrc +0 -0
  68. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/configuration/initramfs-tools/torrc +0 -0
  69. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/configuration/packages/general.txt +0 -0
  70. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/configuration/packages/server/luks-debian.txt +0 -0
  71. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/configuration/packages/server/luks.txt +0 -0
  72. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/configuration/packages/server/tor-debian.txt +0 -0
  73. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/lim/configuration/packages/server/tor.txt +0 -0
  74. {linux_image_manager-2.4.0/lim/data → linux_image_manager-3.0.0/lim/core}/__init__.py +0 -0
  75. {linux_image_manager-2.4.0/lim/image → linux_image_manager-3.0.0/lim/data}/__init__.py +0 -0
  76. {linux_image_manager-2.4.0/lim/storage → linux_image_manager-3.0.0/lim/image}/__init__.py +0 -0
  77. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/linux_image_manager.egg-info/dependency_links.txt +0 -0
  78. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/linux_image_manager.egg-info/entry_points.txt +0 -0
  79. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/linux_image_manager.egg-info/requires.txt +0 -0
  80. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/linux_image_manager.egg-info/top_level.txt +0 -0
  81. {linux_image_manager-2.4.0 → linux_image_manager-3.0.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: linux-image-manager
3
- Version: 2.4.0
3
+ Version: 3.0.0
4
4
  Summary: CLI (`lim`) for downloading, verifying and flashing Linux images, LUKS/Btrfs encrypted storage (single drive and RAID1), image backups and chroot maintenance
5
5
  Author-email: Kevin Veen-Birkenbach <kevin@veen.world>
6
6
  Maintainer-email: Kevin Veen-Birkenbach <kevin@veen.world>
@@ -103,21 +103,34 @@ lim --type chroot
103
103
  main.py # entry point (the `lim` alias)
104
104
  lim/
105
105
  cli.py # argument parsing and command dispatch
106
- catalog.py # read-only access to distributions.yml
107
- device.py # block device selection, dd, blkid helpers
108
- luks.py # LUKS keyfiles, crypttab/fstab bookkeeping
109
- runner.py # subprocess wrapper used by all modules
106
+ catalog.py # read-only access to distributions.yml and pins.yml
107
+ core/ # runner, device, LUKS bookkeeping, UI and errors
110
108
  storage/ # single drive and RAID1 encryption setups
111
- image/ # image setup, backup, chroot, verification
109
+ image/ # image setup, backup, chroot
110
+ image/acquire/ # image selection, download, verification, transfer
111
+ image/security/ # encryption, host key pinning, remote unlock
112
+ image/initramfs/ # mkinitcpio and initramfs-tools Tor unlock backends
112
113
  data/ # encfs lock/unlock and data import/export
113
114
  distributions.yml # single point of truth for the image catalog
115
+ pins.yml # upstream releases, digests and signature floors the update bot refreshes
114
116
  configuration/ # package collections used during image setup
115
117
  tests/unit/ # unit tests (all external commands mocked)
116
118
  tests/e2e/ # Tor onion unlock end-to-end tests (rootless + QEMU, opt-in)
117
119
  tests/e2e/qemu/ # full virtualized build+boot+unlock harness
118
120
  tests/lint/ # architecture guards (e.g. max file length)
121
+ tests/bot/ # tests of the update bot
122
+ .github/scripts/ # update bot (refresh_pins.py)
119
123
  ```
120
124
 
125
+ ## Automatic Updates 🤖
126
+
127
+ - **Dependabot** bumps the GitHub Actions weekly and opens Python security updates; PyYAML is an open version range, so new releases need no bump.
128
+ - **refresh-pins** (weekly) moves *lim/pins.yml* to the newest upstream release of moOde, RetroPie, Manjaro ARM and the RetroFlag shutdown script, with their sha256 digests, and raises the Arch Linux ARM signature floors after verifying the new signature.
129
+ - **auto-merge** squash-merges these bot pull requests once the *tests* workflow passes on their exact head.
130
+ - Trust: this is a deliberate maintainer decision. A new upstream release or RetroFlag script reaches the default branch without a human review; the sha256 pins then guarantee that every user gets exactly the content upstream published, and the RetroFlag script is only copied into the image, never run on the build host. Releases are cut by the maintainer after a security audit of the merged pins.
131
+ - CI runs the newest Python 3, and the QEMU test builds Debian *stable*; the runner image stays pinned.
132
+ - Still pinned by hand, as their upstreams publish no machine-readable releases: TorBox, Android-x86, Manjaro Architect, and new Manjaro GNOME versions. Raspberry Pi OS always downloads the upstream *latest* image.
133
+
121
134
  ## Configuration & Customization 🔧
122
135
 
123
136
  Customize your environment in the `lim/configuration/` folder:
@@ -146,13 +159,14 @@ client:
146
159
  torsocks ssh root@<onion-address>
147
160
  ```
148
161
 
149
- Typing the LUKS passphrase into that shell resumes the boot. The direct
150
- `ssh root@<ip>` unlock keeps working as before; Tor is an additional path,
151
- useful behind NAT/CGNAT where no port forwarding is possible.
162
+ Typing the LUKS passphrase into that shell resumes the boot. Tor is an
163
+ additional path, useful behind NAT/CGNAT where no port forwarding is possible.
164
+ For a direct unlock, run `lim remote-unlock`, pick the saved device and type its
165
+ IP: ssh then checks the host key pinned at build time and refuses any other.
152
166
 
153
167
  **Security note:** the onion private key is stored in the initramfs on the
154
168
  unencrypted boot partition. Anyone with physical access to the SD card can
155
- read it and impersonate the onion service — treat the address as
169
+ read it and impersonate the onion service, so treat the address as
156
170
  non-secret. Access control remains the SSH public key
157
171
  (`/etc/dropbear/root_key`), exactly as with the direct unlock.
158
172
 
@@ -167,7 +181,7 @@ pytest
167
181
  ### Tor unlock end-to-end test
168
182
 
169
183
  `tests/e2e/test_tor_unlock_e2e.py` reproduces the operator-visible half of the
170
- Tor decryption process **rootless** — no block devices, no `cryptsetup`, no
184
+ Tor decryption process **rootless**: no block devices, no `cryptsetup`, no
171
185
  `chroot`. It generates the v3 onion keys offline (exactly as `lim.image.tor`
172
186
  does inside the image), starts a real Tor onion service from a torrc mirroring
173
187
  the baked-in one, then connects to the `.onion` address through Tor and
@@ -188,8 +202,8 @@ is not covered by this rootless test.
188
202
 
189
203
  ### Full virtualized unlock (QEMU)
190
204
 
191
- For the *whole* process — build an encrypted image, boot it, run the real
192
- initramfs Tor+dropbear chain, and unlock it — `tests/e2e/qemu/` drives a QEMU
205
+ For the *whole* process (build an encrypted image, boot it, run the real
206
+ initramfs Tor+dropbear chain, and unlock it), `tests/e2e/qemu/` drives a QEMU
193
207
  virtual machine end to end and asserts the real system booted only after the
194
208
  passphrase was delivered over Tor. It is opt-in (`LIM_E2E_QEMU=1`) and needs
195
209
  QEMU, `arch-install-scripts`, `cryptsetup`, `tor` and `ncat`; the build stage
@@ -197,8 +211,8 @@ needs root (ideally inside a throwaway VM to keep the host rootless). A private,
197
211
  offline Tor network via [chutney](https://gitlab.torproject.org/tpo/core/chutney)
198
212
  is supported. See [tests/e2e/qemu/README.md](tests/e2e/qemu/README.md).
199
213
 
200
- The harness's pure logic and drift guards run in the normal suite
201
- (`test_qemu_harness_unit.py`) — no QEMU, root, or network needed.
214
+ The harness's pure logic runs in the normal suite
215
+ (`test_qemu_harness_unit.py`); it needs no QEMU, root, or network.
202
216
 
203
217
  ## License 📜
204
218
 
@@ -85,21 +85,34 @@ lim --type chroot
85
85
  main.py # entry point (the `lim` alias)
86
86
  lim/
87
87
  cli.py # argument parsing and command dispatch
88
- catalog.py # read-only access to distributions.yml
89
- device.py # block device selection, dd, blkid helpers
90
- luks.py # LUKS keyfiles, crypttab/fstab bookkeeping
91
- runner.py # subprocess wrapper used by all modules
88
+ catalog.py # read-only access to distributions.yml and pins.yml
89
+ core/ # runner, device, LUKS bookkeeping, UI and errors
92
90
  storage/ # single drive and RAID1 encryption setups
93
- image/ # image setup, backup, chroot, verification
91
+ image/ # image setup, backup, chroot
92
+ image/acquire/ # image selection, download, verification, transfer
93
+ image/security/ # encryption, host key pinning, remote unlock
94
+ image/initramfs/ # mkinitcpio and initramfs-tools Tor unlock backends
94
95
  data/ # encfs lock/unlock and data import/export
95
96
  distributions.yml # single point of truth for the image catalog
97
+ pins.yml # upstream releases, digests and signature floors the update bot refreshes
96
98
  configuration/ # package collections used during image setup
97
99
  tests/unit/ # unit tests (all external commands mocked)
98
100
  tests/e2e/ # Tor onion unlock end-to-end tests (rootless + QEMU, opt-in)
99
101
  tests/e2e/qemu/ # full virtualized build+boot+unlock harness
100
102
  tests/lint/ # architecture guards (e.g. max file length)
103
+ tests/bot/ # tests of the update bot
104
+ .github/scripts/ # update bot (refresh_pins.py)
101
105
  ```
102
106
 
107
+ ## Automatic Updates 🤖
108
+
109
+ - **Dependabot** bumps the GitHub Actions weekly and opens Python security updates; PyYAML is an open version range, so new releases need no bump.
110
+ - **refresh-pins** (weekly) moves *lim/pins.yml* to the newest upstream release of moOde, RetroPie, Manjaro ARM and the RetroFlag shutdown script, with their sha256 digests, and raises the Arch Linux ARM signature floors after verifying the new signature.
111
+ - **auto-merge** squash-merges these bot pull requests once the *tests* workflow passes on their exact head.
112
+ - Trust: this is a deliberate maintainer decision. A new upstream release or RetroFlag script reaches the default branch without a human review; the sha256 pins then guarantee that every user gets exactly the content upstream published, and the RetroFlag script is only copied into the image, never run on the build host. Releases are cut by the maintainer after a security audit of the merged pins.
113
+ - CI runs the newest Python 3, and the QEMU test builds Debian *stable*; the runner image stays pinned.
114
+ - Still pinned by hand, as their upstreams publish no machine-readable releases: TorBox, Android-x86, Manjaro Architect, and new Manjaro GNOME versions. Raspberry Pi OS always downloads the upstream *latest* image.
115
+
103
116
  ## Configuration & Customization 🔧
104
117
 
105
118
  Customize your environment in the `lim/configuration/` folder:
@@ -128,13 +141,14 @@ client:
128
141
  torsocks ssh root@<onion-address>
129
142
  ```
130
143
 
131
- Typing the LUKS passphrase into that shell resumes the boot. The direct
132
- `ssh root@<ip>` unlock keeps working as before; Tor is an additional path,
133
- useful behind NAT/CGNAT where no port forwarding is possible.
144
+ Typing the LUKS passphrase into that shell resumes the boot. Tor is an
145
+ additional path, useful behind NAT/CGNAT where no port forwarding is possible.
146
+ For a direct unlock, run `lim remote-unlock`, pick the saved device and type its
147
+ IP: ssh then checks the host key pinned at build time and refuses any other.
134
148
 
135
149
  **Security note:** the onion private key is stored in the initramfs on the
136
150
  unencrypted boot partition. Anyone with physical access to the SD card can
137
- read it and impersonate the onion service — treat the address as
151
+ read it and impersonate the onion service, so treat the address as
138
152
  non-secret. Access control remains the SSH public key
139
153
  (`/etc/dropbear/root_key`), exactly as with the direct unlock.
140
154
 
@@ -149,7 +163,7 @@ pytest
149
163
  ### Tor unlock end-to-end test
150
164
 
151
165
  `tests/e2e/test_tor_unlock_e2e.py` reproduces the operator-visible half of the
152
- Tor decryption process **rootless** — no block devices, no `cryptsetup`, no
166
+ Tor decryption process **rootless**: no block devices, no `cryptsetup`, no
153
167
  `chroot`. It generates the v3 onion keys offline (exactly as `lim.image.tor`
154
168
  does inside the image), starts a real Tor onion service from a torrc mirroring
155
169
  the baked-in one, then connects to the `.onion` address through Tor and
@@ -170,8 +184,8 @@ is not covered by this rootless test.
170
184
 
171
185
  ### Full virtualized unlock (QEMU)
172
186
 
173
- For the *whole* process — build an encrypted image, boot it, run the real
174
- initramfs Tor+dropbear chain, and unlock it — `tests/e2e/qemu/` drives a QEMU
187
+ For the *whole* process (build an encrypted image, boot it, run the real
188
+ initramfs Tor+dropbear chain, and unlock it), `tests/e2e/qemu/` drives a QEMU
175
189
  virtual machine end to end and asserts the real system booted only after the
176
190
  passphrase was delivered over Tor. It is opt-in (`LIM_E2E_QEMU=1`) and needs
177
191
  QEMU, `arch-install-scripts`, `cryptsetup`, `tor` and `ncat`; the build stage
@@ -179,8 +193,8 @@ needs root (ideally inside a throwaway VM to keep the host rootless). A private,
179
193
  offline Tor network via [chutney](https://gitlab.torproject.org/tpo/core/chutney)
180
194
  is supported. See [tests/e2e/qemu/README.md](tests/e2e/qemu/README.md).
181
195
 
182
- The harness's pure logic and drift guards run in the normal suite
183
- (`test_qemu_harness_unit.py`) — no QEMU, root, or network needed.
196
+ The harness's pure logic runs in the normal suite
197
+ (`test_qemu_harness_unit.py`); it needs no QEMU, root, or network.
184
198
 
185
199
  ## License 📜
186
200
 
@@ -0,0 +1 @@
1
+ __version__ = "1.0.0"
@@ -0,0 +1,80 @@
1
+ from functools import cache
2
+
3
+ import yaml
4
+
5
+ from lim import config
6
+
7
+ CATALOG_PATH = config.CATALOG_PATH
8
+ PINS_PATH = config.PINS_PATH
9
+ GITHUB_RELEASE_URL = "https://github.com/{repository}/releases/download/{tag}/"
10
+ RELEASE_REPOSITORIES = {
11
+ "manjaro_arm_rpi4": "manjaro-arm/rpi4-images",
12
+ "moode": "moode-player/moode",
13
+ "retropie": "RetroPie/RetroPie-Setup",
14
+ }
15
+ RETROFLAG_REPOSITORY = "RetroFlag/retroflag-picase"
16
+ RETROFLAG_URL = (
17
+ "https://raw.githubusercontent.com/" + RETROFLAG_REPOSITORY + "/{commit}/SafeShutdown_gpi.py"
18
+ )
19
+
20
+
21
+ @cache
22
+ def _load() -> dict:
23
+ with CATALOG_PATH.open() as handle:
24
+ return yaml.safe_load(handle)
25
+
26
+
27
+ @cache
28
+ def pins() -> dict:
29
+ with PINS_PATH.open() as handle:
30
+ return yaml.safe_load(handle)
31
+
32
+
33
+ def release_image(source: str, key: str) -> dict[str, str]:
34
+ pin = pins()[source]
35
+ image = pin["images"][key]
36
+ return {
37
+ "url": GITHUB_RELEASE_URL.format(repository=RELEASE_REPOSITORIES[source], tag=pin["tag"]),
38
+ "image": image["image"],
39
+ "checksum": image["sha256"],
40
+ }
41
+
42
+
43
+ def arch_rpi_images() -> dict[str, dict[str, str]]:
44
+ floors = pins()["alarm_signature_not_before"]
45
+ return {
46
+ version: {**entry, "signature_not_before": floors[entry["architecture"]]}
47
+ for version, entry in _load()["arch_rpi_images"].items()
48
+ }
49
+
50
+
51
+ def manjaro_gnome_releases() -> dict[str, dict[str, str]]:
52
+ releases = dict(_load()["manjaro_gnome_releases"])
53
+ releases["raspberrypi"] = {
54
+ **releases["raspberrypi"],
55
+ **release_image("manjaro_arm_rpi4", "gnome"),
56
+ }
57
+ return releases
58
+
59
+
60
+ def retropie_images() -> dict[str, dict[str, str]]:
61
+ return {
62
+ version: release_image("retropie", variant)
63
+ for version, variant in _load()["retropie_images"].items()
64
+ }
65
+
66
+
67
+ def retroflag_script() -> dict[str, str]:
68
+ retroflag = pins()["retroflag"]
69
+ return {
70
+ "url": RETROFLAG_URL.format(commit=retroflag["commit"]),
71
+ "sha256": retroflag["sha256"],
72
+ }
73
+
74
+
75
+ def raspios_images() -> dict[str, dict[str, str]]:
76
+ return _load()["raspios_images"]
77
+
78
+
79
+ def mkinitcpio_modules_by_rpi() -> dict[str, str]:
80
+ return _load()["mkinitcpio_modules_by_rpi"]
@@ -1,17 +1,15 @@
1
- """Command line interface: `lim --type <command>`."""
2
-
3
1
  import argparse
4
2
  import sys
5
3
  from collections.abc import Callable
6
4
  from dataclasses import dataclass
7
5
 
8
- from lim import system, ui
6
+ from lim.core import system, ui
7
+ from lim.core.errors import LimError
9
8
  from lim.data import crypt, sync
10
- from lim.errors import LimError
11
9
  from lim.image import backup, chroot
12
10
  from lim.image import setup as image_setup
13
- from lim.image import unlock as image_unlock
14
11
  from lim.image import wizard as image_wizard
12
+ from lim.image.security import unlock as image_unlock
15
13
  from lim.storage import raid1, single_drive
16
14
 
17
15
 
@@ -126,13 +124,13 @@ def build_parser() -> argparse.ArgumentParser:
126
124
  ]
127
125
  parser = argparse.ArgumentParser(
128
126
  prog="lim",
129
- description="Linux Image Manager — manages Linux images and encrypted storage.",
127
+ description="Linux Image Manager: manages Linux images and encrypted storage.",
130
128
  epilog="\n".join(epilog_lines),
131
129
  formatter_class=argparse.RawDescriptionHelpFormatter,
132
130
  )
133
131
  parser.add_argument(
134
132
  "--type",
135
- default="guided",
133
+ default="guided", # nocheck: clean.default-value -- optional CLI flag, documented default
136
134
  choices=list(COMMANDS.keys()),
137
135
  help="Command to execute (default: guided).",
138
136
  )
@@ -1,15 +1,10 @@
1
- """Package and repository paths shared by all modules.
2
-
3
- Configuration and the image catalog ship inside the package so that
4
- wheel installs work; the encfs data store stays repository-relative.
5
- """
6
-
7
1
  from pathlib import Path
8
2
 
9
3
  PACKAGE_ROOT = Path(__file__).resolve().parent
10
4
  CONFIGURATION_PATH = PACKAGE_ROOT / "configuration"
11
5
  PACKAGE_PATH = CONFIGURATION_PATH / "packages"
12
6
  CATALOG_PATH = PACKAGE_ROOT / "distributions.yml"
7
+ PINS_PATH = PACKAGE_ROOT / "pins.yml"
13
8
 
14
9
  REPOSITORY_PATH = PACKAGE_ROOT.parent
15
10
  ENCRYPTED_PATH = REPOSITORY_PATH / ".encrypted"
@@ -0,0 +1,28 @@
1
+ #!/bin/bash
2
+ target="$1"
3
+ for old in pi alarm; do
4
+ id "$old" >/dev/null 2>&1 || continue
5
+ [ "$old" = "$target" ] && continue
6
+ id "$target" >/dev/null 2>&1 && continue
7
+ usermod -l "$target" "$old"
8
+ usermod -d "/home/$target" -m "$target"
9
+ if getent group "$old" >/dev/null; then
10
+ groupmod -n "$target" "$old"
11
+ fi
12
+ break
13
+ done
14
+ id "$target" >/dev/null 2>&1 || useradd -m -s /bin/bash "$target"
15
+ install -d -m 700 "/home/$target/.ssh"
16
+ printf '%s\n' "$2" > "/home/$target/.ssh/authorized_keys"
17
+ chmod 600 "/home/$target/.ssh/authorized_keys"
18
+ chown -R "$target:$target" "/home/$target/.ssh"
19
+ passwd -l root
20
+ install -d -m 750 /etc/sudoers.d
21
+ printf '%s ALL=(ALL:ALL) ALL\n' "$target" > "$3"
22
+ chmod 440 "$3"
23
+ cfg=/etc/ssh/sshd_config
24
+ if [ -f "$cfg" ] && ! grep -qx 'PasswordAuthentication no' "$cfg"; then
25
+ printf '%s\n' 'PasswordAuthentication no' 'ChallengeResponseAuthentication no' | cat - "$cfg" > "$cfg.lim"
26
+ cat "$cfg.lim" > "$cfg"
27
+ rm "$cfg.lim"
28
+ fi
@@ -0,0 +1,19 @@
1
+ #!/bin/bash
2
+ onion_dir="$1"
3
+ mkdir -p "$onion_dir"
4
+ chmod 0700 "$onion_dir"
5
+ : > /tmp/tor-keygen-torrc
6
+ tor -f /tmp/tor-keygen-torrc --DisableNetwork 1 \
7
+ --DataDirectory /tmp/tor-keygen-data \
8
+ --HiddenServiceDir "$onion_dir" \
9
+ --HiddenServicePort "22 127.0.0.1:22" \
10
+ --SocksPort 0 --RunAsDaemon 0 --Log "notice stderr" &
11
+ tor_pid=$!
12
+ for _ in $(seq 1 30); do
13
+ [ -s "$onion_dir/hostname" ] && break
14
+ sleep 1
15
+ done
16
+ kill "$tor_pid" 2>/dev/null
17
+ wait "$tor_pid"
18
+ rm -rf /tmp/tor-keygen-data /tmp/tor-keygen-torrc
19
+ [ -s "$onion_dir/hostname" ]
@@ -1,18 +1,10 @@
1
1
  #!/usr/bin/ash
2
- # mkinitcpio runtime hook: start Tor so the dropbear unlock shell is
3
- # reachable as an onion service while encryptssh waits for the passphrase.
4
- # Installed to /etc/initcpio/hooks/tor by linux-image-manager.
5
2
 
6
- # netconf's ipconfig drops its DHCP lease data (incl. DNS) into
7
- # /tmp/net-*.conf; busybox's resolver only reads /etc/resolv.conf.
8
3
  _tor_write_resolv_conf() {
9
4
  [ -s /etc/resolv.conf ] && return 0
10
5
  local conf dns
11
6
  for conf in /tmp/net-*.conf; do
12
7
  [ -f "$conf" ] || continue
13
- # Extract ONLY the DNS fields with sed; never source these files —
14
- # they hold attacker-controllable DHCP option strings (hostname,
15
- # domain, rootpath), and sourcing would run them as root pre-boot.
16
8
  for dns in $(sed -n 's/^IPV4DNS[01]=//p' "$conf"); do
17
9
  [ -n "$dns" ] && [ "$dns" != "0.0.0.0" ] \
18
10
  && echo "nameserver $dns" >> /etc/resolv.conf
@@ -22,11 +14,7 @@ _tor_write_resolv_conf() {
22
14
  }
23
15
 
24
16
  run_hook() {
25
- # Tor rejects consensus documents when the clock is far off; boards
26
- # without an RTC boot in 1970, so sync before starting Tor. Bounded:
27
- # a failed sync must never block the boot.
28
17
  msg "tor: syncing clock via NTP..."
29
- # Best-effort DNS; a tor_ntp IP literal needs none, so never gate on it.
30
18
  _tor_write_resolv_conf || msg "tor: no DNS from DHCP (fine if tor_ntp is an IP)"
31
19
  /usr/local/bin/busybox timeout 30 \
32
20
  /usr/local/bin/busybox ntpd -n -q -p "${tor_ntp:-pool.ntp.org}" \
@@ -41,7 +29,6 @@ run_hook() {
41
29
  }
42
30
 
43
31
  run_cleanuphook() {
44
- # Nothing from the initramfs may keep running after the pivot.
45
32
  /usr/local/bin/busybox killall tor 2>/dev/null
46
33
  return 0
47
34
  }
@@ -1,17 +1,8 @@
1
1
  #!/bin/bash
2
- # mkinitcpio install hook: Tor onion service for remote LUKS unlock.
3
- # Installed to /etc/initcpio/install/tor by linux-image-manager.
4
2
 
5
3
  build() {
6
4
  add_binary /usr/bin/tor
7
- # Full busybox for the ntpd applet: boards without an RTC (e.g. most
8
- # Raspberry Pis) wake up in 1970, which Tor's consensus checks reject.
9
- # A different target path keeps mkinitcpio's own busybox untouched.
10
5
  add_binary /usr/bin/busybox /usr/local/bin/busybox
11
- # glibc resolves the NTP server hostname via getaddrinfo(), which dlopen()s
12
- # these NSS modules at runtime — add_binary only follows NEEDED libs, so
13
- # without them DNS silently fails, ntpd never syncs, and the clock stays
14
- # at 1970. glibc's built-in default (no nsswitch.conf) is "dns ... files".
15
6
  add_binary /usr/lib/libnss_dns.so.2
16
7
  add_binary /usr/lib/libnss_files.so.2
17
8
  add_file /etc/tor/initramfs-torrc /etc/tor/torrc
@@ -0,0 +1,16 @@
1
+ #!/bin/sh
2
+ PREREQ=""
3
+ prereqs() { echo "$PREREQ"; }
4
+ case "$1" in
5
+ prereqs) prereqs; exit 0 ;;
6
+ esac
7
+
8
+ for proc_dir in /proc/[0-9]*; do
9
+ pid=${proc_dir#/proc/}
10
+ case "$pid" in
11
+ *[!0-9]*) continue ;;
12
+ esac
13
+ [ "$(readlink "/proc/$pid/exe" 2>/dev/null)" = "/usr/bin/tor" ] \
14
+ && kill "$pid" 2>/dev/null
15
+ done
16
+ exit 0
@@ -1,33 +1,26 @@
1
1
  #!/bin/sh
2
- # initramfs-tools build hook: bake the Tor onion service into the initramfs.
3
- # Installed to /etc/initramfs-tools/hooks/tor by linux-image-manager.
4
2
  PREREQ="dropbear"
5
3
  prereqs() { echo "$PREREQ"; }
6
4
  case "$1" in
7
5
  prereqs) prereqs; exit 0 ;;
8
6
  esac
9
7
 
8
+ # shellcheck source=/dev/null
10
9
  . /usr/share/initramfs-tools/hook-functions
11
10
 
12
11
  copy_exec /usr/bin/tor /usr/bin
13
12
 
14
- # glibc resolves the NTP server hostname via getaddrinfo(), which dlopen()s
15
- # these NSS modules at runtime; without them DNS silently fails and the clock
16
- # (RTC-less boards) stays at 1970, so Tor rejects the consensus.
17
13
  for nss in /usr/lib/*/libnss_dns.so.2 /usr/lib/*/libnss_files.so.2 \
18
14
  /lib/*/libnss_dns.so.2 /lib/*/libnss_files.so.2; do
19
15
  [ -e "$nss" ] && copy_exec "$nss"
20
16
  done
21
17
 
22
- # Full busybox for the ntpd applet (the initramfs busybox may lack it); a
23
- # distinct path keeps the initramfs's own busybox untouched.
24
18
  for bb in /bin/busybox /usr/bin/busybox; do
25
19
  [ -x "$bb" ] && { copy_exec "$bb" /usr/local/bin/busybox; break; }
26
20
  done
27
21
 
28
22
  date -u +%s > "${DESTDIR}/etc/tor-clock-floor"
29
23
 
30
- # Onion keys + torrc, staged on the system by lim.
31
24
  mkdir -p "${DESTDIR}/etc/tor/onion"
32
25
  for key in hostname hs_ed25519_public_key hs_ed25519_secret_key; do
33
26
  cp -a "/etc/tor/initramfs-onion/${key}" "${DESTDIR}/etc/tor/onion/${key}"
@@ -1,33 +1,24 @@
1
1
  #!/bin/sh
2
- # initramfs-tools runtime hook: bring up networking, sync the clock and start
3
- # the Tor onion service so the dropbear unlock shell is reachable while
4
- # cryptsetup waits. Installed to /etc/initramfs-tools/scripts/init-premount/tor.
5
2
  PREREQ=""
6
3
  prereqs() { echo "$PREREQ"; }
7
4
  case "$1" in
8
5
  prereqs) prereqs; exit 0 ;;
9
6
  esac
10
7
 
8
+ # shellcheck source=/dev/null
11
9
  . /scripts/functions
12
10
 
13
11
  log_begin_msg "tor: bringing up networking and starting the onion service"
14
12
 
15
- # init-premount runs BEFORE the cryptroot/dropbear networking, so Tor would
16
- # start with no network and never publish the onion. Bring the interface up
17
- # ourselves from the ip= cmdline (idempotent; the later dropbear setup reuses
18
- # the lease in /run/net-*.conf).
19
13
  configure_networking
20
14
 
21
- # initramfs-tools does not export arbitrary cmdline params as shell vars.
22
15
  tor_ntp=$(sed -n 's/.*\btor_ntp=\([^ ]*\).*/\1/p' /proc/cmdline)
16
+ ntp_server=${tor_ntp:-pool.ntp.org} # nocheck: clean.default-value -- tor_ntp is an optional boot parameter
23
17
 
24
- # Best-effort DNS from the DHCP lease; extract ONLY the DNS fields with sed,
25
- # never source the files (attacker-controllable DHCP option strings would run
26
- # as root pre-boot).
27
18
  if [ ! -s /etc/resolv.conf ]; then
28
19
  for conf in /run/net-*.conf /tmp/net-*.conf; do
29
20
  [ -f "$conf" ] || continue
30
- for dns in $(sed -n 's/^IPV4DNS[01]=//p' "$conf"); do
21
+ sed -n 's/^IPV4DNS[01]=//p' "$conf" | while read -r dns; do
31
22
  [ -n "$dns" ] && [ "$dns" != "0.0.0.0" ] \
32
23
  && echo "nameserver $dns" >> /etc/resolv.conf
33
24
  done
@@ -36,13 +27,15 @@ fi
36
27
 
37
28
  floor=$(cat /etc/tor-clock-floor 2>/dev/null || echo 0)
38
29
  if [ "$(date +%s)" -lt "$floor" ]; then
39
- /usr/local/bin/busybox date -s "@$floor" >/dev/null 2>&1 \
40
- || date -s "@$floor" >/dev/null 2>&1 || true
30
+ if ! /usr/local/bin/busybox date -s "@$floor" >/dev/null 2>&1 \
31
+ && ! date -s "@$floor" >/dev/null 2>&1; then
32
+ log_warning_msg "tor: could not raise the clock to the build-time floor"
33
+ fi
41
34
  fi
42
35
 
43
36
  if [ -x /usr/local/bin/busybox ]; then
44
37
  /usr/local/bin/busybox timeout 30 \
45
- /usr/local/bin/busybox ntpd -n -q -p "${tor_ntp:-pool.ntp.org}" \
38
+ /usr/local/bin/busybox ntpd -n -q -p "$ntp_server" \
46
39
  || log_warning_msg "tor: NTP sync failed, keeping current clock"
47
40
  fi
48
41
 
@@ -1,11 +1,9 @@
1
- """Block-device selection and low-level device helpers."""
2
-
3
1
  import stat as stat_module
4
2
  from dataclasses import dataclass
5
3
  from pathlib import Path
6
4
 
7
- from lim import runner, ui
8
- from lim.errors import LimError
5
+ from lim.core import runner, ui
6
+ from lim.core.errors import LimError
9
7
 
10
8
  SYS_BLOCK_PATH = Path("/sys/block")
11
9
 
@@ -26,11 +24,7 @@ Recommendation: For deleting a GPT partition table, use a block size of 512 byte
26
24
  ##########################################################################################"""
27
25
 
28
26
 
29
- def optimal_blocksize(name: str, sys_block_path: Path = SYS_BLOCK_PATH) -> str:
30
- """64 * physical block size, or "4K" when the size cannot be read.
31
-
32
- See https://www.heise.de/ct/hotline/Optimale-Blockgroesse-fuer-dd-2056768.html
33
- """
27
+ def optimal_blocksize(name: str, sys_block_path: Path) -> str:
34
28
  size_path = sys_block_path / name / "queue" / "physical_block_size"
35
29
  try:
36
30
  return str(64 * int(size_path.read_text().strip()))
@@ -40,7 +34,7 @@ def optimal_blocksize(name: str, sys_block_path: Path = SYS_BLOCK_PATH) -> str:
40
34
 
41
35
  @dataclass(frozen=True)
42
36
  class Device:
43
- name: str # e.g. "sda" or "mmcblk0"
37
+ name: str
44
38
 
45
39
  @property
46
40
  def path(self) -> str:
@@ -48,10 +42,9 @@ class Device:
48
42
 
49
43
  @property
50
44
  def optimal_blocksize(self) -> str:
51
- return optimal_blocksize(self.name)
45
+ return optimal_blocksize(self.name, SYS_BLOCK_PATH)
52
46
 
53
47
  def partition(self, number: int) -> str:
54
- """/dev/sda -> /dev/sda1, /dev/mmcblk0 -> /dev/mmcblk0p1."""
55
48
  if self.name[-1].isdigit():
56
49
  return f"{self.path}p{number}"
57
50
  return f"{self.path}{number}"
@@ -77,7 +70,6 @@ def select_device() -> Device:
77
70
 
78
71
 
79
72
  def overwrite_device(device: Device) -> None:
80
- """Optionally overwrite the device (or its first blocks) with zeros."""
81
73
  print(PARTITION_TABLE_INFO)
82
74
  answer = ui.ask(
83
75
  f"Should {device.path} be overwritten with zeros before copying? (y/N/block count)"
@@ -118,11 +110,9 @@ def overwrite_device(device: Device) -> None:
118
110
 
119
111
 
120
112
  def blkid_value(path: str, tag: str) -> str:
121
- """Return a blkid tag value ("TYPE", "UUID", ...) or "" when unavailable."""
122
113
  return runner.output(["blkid", path, "-s", tag, "-o", "value"], sudo=True, check=False)
123
114
 
124
115
 
125
116
  def is_mounted(path_fragment: str) -> bool:
126
- """Whether any current mount line contains the given fragment."""
127
117
  mounts = runner.output(["mount"], check=False)
128
118
  return any(path_fragment in line for line in mounts.splitlines())
@@ -0,0 +1,2 @@
1
+ class LimError(Exception):
2
+ pass