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") {
|
if options.Changed("DetachKeys") {
|
||||||
params.Add("detachKeys", options.GetDetachKeys())
|
params.Add("detachKeys", options.GetDetachKeys())
|
||||||
|
|
||||||
detachKeysInBytes, err = term.ToBytes(options.GetDetachKeys())
|
// Empty string disables detaching; do not attempt to parse
|
||||||
if err != nil {
|
if options.GetDetachKeys() == "" {
|
||||||
return fmt.Errorf("invalid detach keys: %w", err)
|
detachKeysInBytes = []byte{}
|
||||||
|
} else {
|
||||||
|
detachKeysInBytes, err = term.ToBytes(options.GetDetachKeys())
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("invalid detach keys: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if isSet.stdin {
|
if isSet.stdin {
|
||||||
|
|||||||
@@ -1226,6 +1226,14 @@ EOF
|
|||||||
run_podman rm $ctr_name
|
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
|
# 15895: --privileged + --systemd = hide /dev/ttyNN
|
||||||
# bats test_tags=ci:parallel
|
# bats test_tags=ci:parallel
|
||||||
@test "podman run --privileged as root with systemd will not mount /dev/tty" {
|
@test "podman run --privileged as root with systemd will not mount /dev/tty" {
|
||||||
|
|||||||
Reference in New Issue
Block a user