mirror of
https://github.com/fscotto/infra.git
synced 2026-11-25 21:29:51 +00:00
Fix media mount permissions and update Fedora 45 packages
This commit is contained in:
@@ -8,7 +8,10 @@ fedora_packages_base:
|
|||||||
- htop
|
- htop
|
||||||
- jq
|
- jq
|
||||||
- make
|
- make
|
||||||
- nodejs
|
# Keep the LTS stream explicit. Fedora 45's rolling `nodejs` package
|
||||||
|
# conflicts with the nodejs22-bin alternative installed by the F44→F45
|
||||||
|
# upgrade.
|
||||||
|
- nodejs22
|
||||||
- openssl
|
- openssl
|
||||||
- ripgrep
|
- ripgrep
|
||||||
|
|
||||||
@@ -73,6 +76,7 @@ chatgpt_desktop_enabled: false
|
|||||||
chatgpt_desktop_supported_fedora_versions:
|
chatgpt_desktop_supported_fedora_versions:
|
||||||
- "43"
|
- "43"
|
||||||
- "44"
|
- "44"
|
||||||
|
- "45"
|
||||||
chatgpt_desktop_supported_architectures:
|
chatgpt_desktop_supported_architectures:
|
||||||
- x86_64
|
- x86_64
|
||||||
- aarch64
|
- aarch64
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ manage_volume() {
|
|||||||
fi
|
fi
|
||||||
[[ "$(mount_info "$external_mount")" == "$mapper_id /" ]] ||
|
[[ "$(mount_info "$external_mount")" == "$mapper_id /" ]] ||
|
||||||
fail "The LUKS volume is not mounted at the expected path: $external_mount"
|
fail "The LUKS volume is not mounted at the expected path: $external_mount"
|
||||||
systemctl start "$automount_unit" "$bind_unit"
|
sudo systemctl start "$automount_unit" "$bind_unit"
|
||||||
require_external_bind
|
require_external_bind
|
||||||
echo "Encrypted media storage mounted at $root"
|
echo "Encrypted media storage mounted at $root"
|
||||||
else
|
else
|
||||||
@@ -71,7 +71,7 @@ manage_volume() {
|
|||||||
--filter ancestor=localhost/ai-media-rvc:managed)
|
--filter ancestor=localhost/ai-media-rvc:managed)
|
||||||
[[ -z "$jobs" && -z "$containers" ]] ||
|
[[ -z "$jobs" && -z "$containers" ]] ||
|
||||||
fail "Stop the running ai-media jobs and applications before unmounting"
|
fail "Stop the running ai-media jobs and applications before unmounting"
|
||||||
systemctl stop ai-media-bind-restarter.service "$automount_unit" "$bind_unit"
|
sudo systemctl stop ai-media-bind-restarter.service "$automount_unit" "$bind_unit"
|
||||||
[[ -z "$(mount_info "$root")" ]] || fail "The media bind mount is still in use"
|
[[ -z "$(mount_info "$root")" ]] || fail "The media bind mount is still in use"
|
||||||
mounted=$(volume_mounts)
|
mounted=$(volume_mounts)
|
||||||
if [[ -n "$mounted" ]]; then
|
if [[ -n "$mounted" ]]; then
|
||||||
|
|||||||
Binary file not shown.
@@ -49,7 +49,9 @@ root = os.environ["STORAGE_TEST_ROOT"]
|
|||||||
external = "/run/media/test/Backup"
|
external = "/run/media/test/Backup"
|
||||||
with open(os.environ["STORAGE_TEST_LOG"], "a") as log:
|
with open(os.environ["STORAGE_TEST_LOG"], "a") as log:
|
||||||
log.write(json.dumps([cmd, *args]) + "\\n")
|
log.write(json.dumps([cmd, *args]) + "\\n")
|
||||||
if cmd == "lsblk":
|
if cmd == "sudo":
|
||||||
|
os.execvp(args[0], args)
|
||||||
|
elif cmd == "lsblk":
|
||||||
if state.get("missing"):
|
if state.get("missing"):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
print("/dev/sda1 part 8:1")
|
print("/dev/sda1 part 8:1")
|
||||||
@@ -98,12 +100,16 @@ elif cmd == "udisksctl":
|
|||||||
state_file.write_text(json.dumps(state))
|
state_file.write_text(json.dumps(state))
|
||||||
''')
|
''')
|
||||||
mock.chmod(0o755)
|
mock.chmod(0o755)
|
||||||
for command in ("lsblk", "findmnt", "systemctl", "podman", "udisksctl"):
|
for command in ("lsblk", "findmnt", "systemctl", "podman", "udisksctl", "sudo"):
|
||||||
(self.root / command).symlink_to(mock)
|
(self.root / command).symlink_to(mock)
|
||||||
self.env = dict(os.environ, PATH=f"{self.root}:{os.environ['PATH']}",
|
self.env = dict(os.environ, PATH=f"{self.root}:{os.environ['PATH']}",
|
||||||
STORAGE_TEST_STATE=str(self.state), STORAGE_TEST_LOG=str(self.log),
|
STORAGE_TEST_STATE=str(self.state), STORAGE_TEST_LOG=str(self.log),
|
||||||
STORAGE_TEST_ROOT=str(self.media))
|
STORAGE_TEST_ROOT=str(self.media))
|
||||||
|
|
||||||
|
def units(self):
|
||||||
|
return [subprocess.check_output(["systemd-escape", "-p", "--suffix=" + suffix, "--", str(self.media)], text=True).strip()
|
||||||
|
for suffix in ("automount", "mount")]
|
||||||
|
|
||||||
def launch(self, *args, **state):
|
def launch(self, *args, **state):
|
||||||
self.state.write_text(json.dumps(state))
|
self.state.write_text(json.dumps(state))
|
||||||
self.log.write_text("")
|
self.log.write_text("")
|
||||||
@@ -111,7 +117,7 @@ state_file.write_text(json.dumps(state))
|
|||||||
capture_output=True, text=True, timeout=10)
|
capture_output=True, text=True, timeout=10)
|
||||||
operations = [row[:2] if row[0] == "systemctl" else row
|
operations = [row[:2] if row[0] == "systemctl" else row
|
||||||
for line in self.log.read_text().splitlines()
|
for line in self.log.read_text().splitlines()
|
||||||
if (row := json.loads(line))[0] in ("udisksctl", "systemctl")]
|
if (row := json.loads(line))[0] in ("udisksctl", "systemctl", "sudo")]
|
||||||
return result, operations
|
return result, operations
|
||||||
|
|
||||||
def test_mount_unlocks_only_the_configured_volume_then_starts_bind(self):
|
def test_mount_unlocks_only_the_configured_volume_then_starts_bind(self):
|
||||||
@@ -120,20 +126,21 @@ state_file.write_text(json.dumps(state))
|
|||||||
self.assertEqual(operations, [
|
self.assertEqual(operations, [
|
||||||
["udisksctl", "unlock", "--block-device", f"/dev/disk/by-uuid/{UUID}"],
|
["udisksctl", "unlock", "--block-device", f"/dev/disk/by-uuid/{UUID}"],
|
||||||
["udisksctl", "mount", "--block-device", "/dev/dm-0"],
|
["udisksctl", "mount", "--block-device", "/dev/dm-0"],
|
||||||
|
["sudo", "systemctl", "start", *self.units()],
|
||||||
["systemctl", "start"],
|
["systemctl", "start"],
|
||||||
])
|
])
|
||||||
|
|
||||||
def test_mount_does_not_reopen_already_mounted_volume(self):
|
def test_mount_does_not_reopen_already_mounted_volume(self):
|
||||||
result, operations = self.launch("mount", unlocked=True, mounted="252:0 /")
|
result, operations = self.launch("mount", unlocked=True, mounted="252:0 /")
|
||||||
self.assertEqual(result.returncode, 0, result.stderr)
|
self.assertEqual(result.returncode, 0, result.stderr)
|
||||||
self.assertEqual(operations, [["systemctl", "start"]])
|
self.assertEqual(operations, [["sudo", "systemctl", "start", *self.units()], ["systemctl", "start"]])
|
||||||
|
|
||||||
def test_umount_stops_bind_before_unmount_and_lock(self):
|
def test_umount_stops_bind_before_unmount_and_lock(self):
|
||||||
result, operations = self.launch("umount", unlocked=True, mounted="252:0 /",
|
result, operations = self.launch("umount", unlocked=True, mounted="252:0 /",
|
||||||
bind="252:0 /ai-media")
|
bind="252:0 /ai-media")
|
||||||
self.assertEqual(result.returncode, 0, result.stderr)
|
self.assertEqual(result.returncode, 0, result.stderr)
|
||||||
self.assertEqual(operations, [
|
self.assertEqual(operations, [
|
||||||
["systemctl", "--user"], ["systemctl", "stop"],
|
["systemctl", "--user"], ["sudo", "systemctl", "stop", "ai-media-bind-restarter.service", *self.units()], ["systemctl", "stop"],
|
||||||
["udisksctl", "unmount", "--block-device", "/dev/dm-0"],
|
["udisksctl", "unmount", "--block-device", "/dev/dm-0"],
|
||||||
["udisksctl", "lock", "--block-device", f"/dev/disk/by-uuid/{UUID}"],
|
["udisksctl", "lock", "--block-device", f"/dev/disk/by-uuid/{UUID}"],
|
||||||
])
|
])
|
||||||
@@ -155,7 +162,7 @@ state_file.write_text(json.dumps(state))
|
|||||||
result, operations = self.launch("umount", unlocked=True, mounted="252:0 /",
|
result, operations = self.launch("umount", unlocked=True, mounted="252:0 /",
|
||||||
other_mounts=["/mnt/other"])
|
other_mounts=["/mnt/other"])
|
||||||
self.assertNotEqual(result.returncode, 0)
|
self.assertNotEqual(result.returncode, 0)
|
||||||
self.assertEqual(operations, [["systemctl", "--user"], ["systemctl", "stop"]])
|
self.assertEqual(operations, [["systemctl", "--user"], ["sudo", "systemctl", "stop", "ai-media-bind-restarter.service", *self.units()], ["systemctl", "stop"]])
|
||||||
|
|
||||||
def test_rejects_foreign_mount_missing_device_and_extra_arguments(self):
|
def test_rejects_foreign_mount_missing_device_and_extra_arguments(self):
|
||||||
for args, state in [
|
for args, state in [
|
||||||
|
|||||||
Reference in New Issue
Block a user