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 <shivammittal42006@gmail.com>
This commit is contained in:
shiavm006
2025-11-04 09:12:02 +05:30
parent 8aea109e42
commit c0ae1a9bac
2 changed files with 16 additions and 3 deletions

View File

@@ -80,11 +80,16 @@ func Attach(ctx context.Context, nameOrID string, stdin io.Reader, stdout io.Wri
if options.Changed("DetachKeys") {
params.Add("detachKeys", options.GetDetachKeys())
// Empty string disables detaching; do not attempt to parse
if options.GetDetachKeys() == "" {
detachKeysInBytes = []byte{}
} else {
detachKeysInBytes, err = term.ToBytes(options.GetDetachKeys())
if err != nil {
return fmt.Errorf("invalid detach keys: %w", err)
}
}
}
if isSet.stdin {
params.Add("stdin", "true")
}

View File

@@ -1226,6 +1226,14 @@ EOF
run_podman rm $ctr_name
}
# Regression test for https://github.com/containers/podman/issues/27414
# bats test_tags=ci:parallel
@test "podman run with empty --detach-keys" {
# Empty string should disable detaching, not error with "invalid detach keys"
run_podman run --rm --detach-keys="" $IMAGE echo "success"
is "$output" "success" "empty detach-keys should work"
}
# 15895: --privileged + --systemd = hide /dev/ttyNN
# bats test_tags=ci:parallel
@test "podman run --privileged as root with systemd will not mount /dev/tty" {