diff --git a/Sources/tart/Commands/Run.swift b/Sources/tart/Commands/Run.swift index a13bdb6..ad22bf1 100644 --- a/Sources/tart/Commands/Run.swift +++ b/Sources/tart/Commands/Run.swift @@ -227,7 +227,7 @@ struct Run: AsyncParsableCommand { @Option(help: ArgumentHelp("Connected Unix stream socket file descriptor to use for the Softnet control channel (e.g. --net-softnet-control-fd=3)", discussion: """ This option enables the Softnet control channel on an inherited Unix stream socket. It can be used to dynamically replace Softnet allow and block lists while the VM is running. - The file descriptor must be greater than 2. Implies --net-softnet unless --net-host is specified. + The file descriptor must be greater than 2. Implies --net-softnet. """, valueName: "file descriptor")) var netSoftnetControlFd: Int32? @@ -320,7 +320,7 @@ struct Run: AsyncParsableCommand { } // Automatically enable --net-softnet when any of its related options are specified - if netSoftnetAllow != nil || netSoftnetBlock != nil || netSoftnetExpose != nil || (netSoftnetControlFd != nil && !netHost) { + if netSoftnetAllow != nil || netSoftnetBlock != nil || netSoftnetExpose != nil || netSoftnetControlFd != nil { netSoftnet = true } diff --git a/Tests/TartTests/SoftnetControlFDTests.swift b/Tests/TartTests/SoftnetControlFDTests.swift index 13d1888..59696bc 100644 --- a/Tests/TartTests/SoftnetControlFDTests.swift +++ b/Tests/TartTests/SoftnetControlFDTests.swift @@ -139,18 +139,16 @@ final class SoftnetControlFDTests: XCTestCase { XCTAssertEqual(command.netSoftnetControlFd, 3) } - func testControlFDWorksWithHostNetworking() throws { + func testControlFDIsRejectedWithHostNetworking() throws { let temporaryHome = try createTemporaryTartHome() defer { try? FileManager.default.removeItem(at: temporaryHome) } let previousHome = ProcessInfo.processInfo.environment["TART_HOME"] setenv("TART_HOME", temporaryHome.path, 1) defer { restoreEnvironment("TART_HOME", value: previousHome) } - let command = try Run.parse(["vm", "--net-host", "--net-softnet-control-fd", "3"]) - - XCTAssertTrue(command.netHost) - XCTAssertFalse(command.netSoftnet) - XCTAssertEqual(command.netSoftnetControlFd, 3) + XCTAssertThrowsError( + try Run.parse(["vm", "--net-host", "--net-softnet-control-fd", "3"]) + ) } private func createTemporaryTartHome() throws -> URL {