Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Test pinned directory permissions against path replacement

Lakrda1237c7e081
diff --git a/VPhoneKit/VPhoneCoreKitTests/Process/ConfinedDirectoryTests.swift b/VPhoneKit/VPhoneCoreKitTests/Process/ConfinedDirectoryTests.swift
index fc664d9b..48fd9d58 100644
--- a/VPhoneKit/VPhoneCoreKitTests/Process/ConfinedDirectoryTests.swift
+++ b/VPhoneKit/VPhoneCoreKitTests/Process/ConfinedDirectoryTests.swift
@@ -4,6 +4,19 @@ import Testing
@testable import VPhoneCoreKit
struct ConfinedDirectoryTests {
+ @Test func `directory permissions stay on the pinned inode after a path swap`() throws {
+ let tree = try Tree()
+ defer { tree.remove() }
+ let directory = try VPhoneConfinedDirectory(root: tree.root.path)
+ let originalOutsideMode = mode(tree.outside) & 0o777
+ let moved = tree.base.appendingPathComponent("moved")
+ try FileManager.default.moveItem(at: tree.root, to: moved)
+ try FileManager.default.createSymbolicLink(at: tree.root, withDestinationURL: tree.outside)
+ try directory.setPermissions(mode: 0o700)
+ #expect(mode(moved) & 0o777 == 0o700)
+ #expect(mode(tree.outside) & 0o777 == originalOutsideMode)
+ }
+
/// A canonical scratch tree: `root/` is the confinement root, `outside/`
/// holds `keep`, and `root/link` points at `outside/`.
private struct Tree {