Skip to content

Commit c0ae1a9

Browse files
committed
Fix remote client rejecting empty --detach-keys string
The remote client (podman --remote) was incorrectly throwing an error when --detach-keys="" was specified for attach, run, or start commands. According to documentation and the v1.7.0 release notes, specifying an empty string should disable detaching, not cause an error. Fixes: #27414 Signed-off-by: shiavm006 <[email protected]>
1 parent 8aea109 commit c0ae1a9

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

pkg/bindings/containers/attach.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,14 @@ func Attach(ctx context.Context, nameOrID string, stdin io.Reader, stdout io.Wri
8080
if options.Changed("DetachKeys") {
8181
params.Add("detachKeys", options.GetDetachKeys())
8282

83-
detachKeysInBytes, err = term.ToBytes(options.GetDetachKeys())
84-
if err != nil {
85-
return fmt.Errorf("invalid detach keys: %w", err)
83+
// Empty string disables detaching; do not attempt to parse
84+
if options.GetDetachKeys() == "" {
85+
detachKeysInBytes = []byte{}
86+
} else {
87+
detachKeysInBytes, err = term.ToBytes(options.GetDetachKeys())
88+
if err != nil {
89+
return fmt.Errorf("invalid detach keys: %w", err)
90+
}
8691
}
8792
}
8893
if isSet.stdin {

test/system/030-run.bats

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,14 @@ EOF
12261226
run_podman rm $ctr_name
12271227
}
12281228

1229+
# Regression test for https://github.com/containers/podman/issues/27414
1230+
# bats test_tags=ci:parallel
1231+
@test "podman run with empty --detach-keys" {
1232+
# Empty string should disable detaching, not error with "invalid detach keys"
1233+
run_podman run --rm --detach-keys="" $IMAGE echo "success"
1234+
is "$output" "success" "empty detach-keys should work"
1235+
}
1236+
12291237
# 15895: --privileged + --systemd = hide /dev/ttyNN
12301238
# bats test_tags=ci:parallel
12311239
@test "podman run --privileged as root with systemd will not mount /dev/tty" {

0 commit comments

Comments
 (0)