mirror of
https://github.com/containers/podman.git
synced 2025-11-29 01:28:22 +08:00
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:
@@ -80,9 +80,14 @@ func Attach(ctx context.Context, nameOrID string, stdin io.Reader, stdout io.Wri
|
||||
if options.Changed("DetachKeys") {
|
||||
params.Add("detachKeys", options.GetDetachKeys())
|
||||
|
||||
detachKeysInBytes, err = term.ToBytes(options.GetDetachKeys())
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid detach keys: %w", err)
|
||||
// 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 {
|
||||
|
||||
@@ -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" {
|
||||
|
||||
Reference in New Issue
Block a user