Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Plugins/MachineAPIServer/Resources/init
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if [ "$1" = "-s" ]; then
if [ $# -gt 0 ]; then
exec "${USER_SHELL:-${SHELL}}" -c "$*"
else
exec "${USER_SHELL:-${SHELL}}"
exec "${USER_SHELL:-${SHELL}}" -l
fi
elif [ "$1" = "-u" ]; then
# DEPRECATED 0.11.0.0 - use `id` instead of checking `${MACHINE_INITIALIZED}` for backward compatibility, remove in 0.13.0.0
Expand Down
27 changes: 27 additions & 0 deletions Tests/IntegrationTests/Machine/TestCLIMachineRuntimeSerial.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,33 @@ struct TestCLIMachineRuntimeSerial {
}
}

@Test func testDefaultRunStartsLoginShell() async throws {
try await ContainerFixture.with { f in
let name = "\(f.testID)-machine"
f.addCleanup { f.cleanupMachine(name) }
try f.doMachineCreate(name: name, image: machineImage)
try f.doMachineBoot(name: name)
try await f.waitForMachineStatus(name, status: "running")

let sentinel = "login-shell-\(UUID().uuidString)"
let marker = "/tmp/\(sentinel)"
_ = try f.doMachineRun(
name: name,
command: ["printf", "'touch \(marker)\\n'", ">", "$HOME/.profile"]
)

try f.runMachine(["run", "--detach", "-n", name]).check(
"default machine run should start a login shell")
try await Task.sleep(for: .seconds(1))
let result = try f.runMachine(["run", "-n", name, "test", "-f", marker])

#expect(
result.status == 0,
"default machine shell did not source ~/.profile"
)
}
}

@Test func testRunAsRoot() async throws {
try await ContainerFixture.with { f in
let name = "\(f.testID)-machine"
Expand Down