mirror of https://github.com/containers/podman.git
Allow users to disable detach keys
If user specifies --detach-keys="", this will disable the feature. Adding define.DefaultDetachKeys to help screen to help identify detach keys. Updated man pages with additonal information. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
a904e21cf0
commit
7c623bd41f
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"github.com/containers/libpod/cmd/podman/cliconfig"
|
||||
"github.com/containers/libpod/libpod/define"
|
||||
"github.com/containers/libpod/pkg/adapter"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -31,7 +32,7 @@ func init() {
|
|||
attachCommand.SetHelpTemplate(HelpTemplate())
|
||||
attachCommand.SetUsageTemplate(UsageTemplate())
|
||||
flags := attachCommand.Flags()
|
||||
flags.StringVar(&attachCommand.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`")
|
||||
flags.StringVar(&attachCommand.DetachKeys, "detach-keys", define.DefaultDetachKeys, "Select the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`")
|
||||
flags.BoolVar(&attachCommand.NoStdin, "no-stdin", false, "Do not attach STDIN. The default is false")
|
||||
flags.BoolVar(&attachCommand.SigProxy, "sig-proxy", true, "Proxy received signals to the process")
|
||||
flags.BoolVarP(&attachCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
|
||||
|
|
|
@ -188,7 +188,7 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
|
|||
"Run container in background and print container ID",
|
||||
)
|
||||
createFlags.String(
|
||||
"detach-keys", "",
|
||||
"detach-keys", define.DefaultDetachKeys,
|
||||
"Override the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`",
|
||||
)
|
||||
createFlags.StringSlice(
|
||||
|
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"github.com/containers/libpod/cmd/podman/cliconfig"
|
||||
"github.com/containers/libpod/libpod/define"
|
||||
"github.com/containers/libpod/pkg/adapter"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -34,7 +35,7 @@ func init() {
|
|||
execCommand.SetUsageTemplate(UsageTemplate())
|
||||
flags := execCommand.Flags()
|
||||
flags.SetInterspersed(false)
|
||||
flags.StringVar(&execCommand.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _")
|
||||
flags.StringVar(&execCommand.DetachKeys, "detach-keys", define.DefaultDetachKeys, "Select the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _")
|
||||
flags.StringArrayVarP(&execCommand.Env, "env", "e", []string{}, "Set environment variables")
|
||||
flags.BoolVarP(&execCommand.Interactive, "interactive", "i", false, "Keep STDIN open even if not attached")
|
||||
flags.BoolVarP(&execCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
|
||||
|
|
|
@ -35,7 +35,7 @@ func init() {
|
|||
startCommand.SetUsageTemplate(UsageTemplate())
|
||||
flags := startCommand.Flags()
|
||||
flags.BoolVarP(&startCommand.Attach, "attach", "a", false, "Attach container's STDOUT and STDERR")
|
||||
flags.StringVar(&startCommand.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`")
|
||||
flags.StringVar(&startCommand.DetachKeys, "detach-keys", define.DefaultDetachKeys, "Select the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`")
|
||||
flags.BoolVarP(&startCommand.Interactive, "interactive", "i", false, "Keep STDIN open even if not attached")
|
||||
flags.BoolVarP(&startCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
|
||||
flags.BoolVar(&startCommand.SigProxy, "sig-proxy", false, "Proxy received signals to the process (default true if attaching, false otherwise)")
|
||||
|
|
|
@ -20,9 +20,7 @@ it in the **libpod.conf** file: see **libpod.conf(5)** for more information.
|
|||
## OPTIONS
|
||||
**--detach-keys**=*sequence*
|
||||
|
||||
Override the key sequence for detaching a container. Format is a single character `[a-Z]` or
|
||||
a comma separated sequence of `ctrl-<value>`, where `<value>` is one of:
|
||||
`a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`.
|
||||
Specify the key sequence for detaching a container. Format is a single character `[a-Z]` or one or more `ctrl-<value>` characters where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. Specifying "" will disable this feature. The default is *ctrl-p,ctrl-q*.
|
||||
|
||||
**--latest**, **-l**
|
||||
|
||||
|
|
|
@ -196,9 +196,7 @@ it in the **libpod.conf** file: see **libpod.conf(5)** for more information.
|
|||
|
||||
**--detach-keys**=*sequence*
|
||||
|
||||
Override the key sequence for detaching a container. Format is a single character `[a-Z]` or
|
||||
a comma separated sequence of `ctrl-<value>`, where `<value>` is one of:
|
||||
`a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`.
|
||||
Specify the key sequence for detaching a container. Format is a single character `[a-Z]` or one or more `ctrl-<value>` characters where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. Specifying "" will disable this feature. The default is *ctrl-p,ctrl-q*.
|
||||
|
||||
**--device**=*device*
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ podman\-exec - Execute a command in a running container
|
|||
|
||||
**--detach-keys**=*sequence*
|
||||
|
||||
Override the key sequence for detaching a container. Format is a single character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`.
|
||||
Specify the key sequence for detaching a container. Format is a single character `[a-Z]` or one or more `ctrl-<value>` characters where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. Specifying "" will disable this feature. The default is *ctrl-p,ctrl-q*.
|
||||
|
||||
**--env**, **-e**
|
||||
|
||||
|
|
|
@ -202,9 +202,7 @@ it in the **libpod.conf** file: see **libpod.conf(5)** for more information.
|
|||
|
||||
**--detach-keys**=*sequence*
|
||||
|
||||
Override the key sequence for detaching a container. Format is a single character `[a-Z]` or
|
||||
a comma separated sequence of `ctrl-<value>`, where `<value>` is one of:
|
||||
`a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`.
|
||||
Specify the key sequence for detaching a container. Format is a single character `[a-Z]` or one or more `ctrl-<value>` characters where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. Specifying "" will disable this feature. The default is *ctrl-p,ctrl-q*.
|
||||
|
||||
**--device**=*device*
|
||||
|
||||
|
|
|
@ -23,9 +23,7 @@ starting multiple containers.
|
|||
|
||||
**--detach-keys**=*sequence*
|
||||
|
||||
Override the key sequence for detaching a container. Format is a single character `[a-Z]` or
|
||||
a comma separated sequence of `ctrl-<value>`, where `<value>` is one of:
|
||||
`a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`.
|
||||
Specify the key sequence for detaching a container. Format is a single character `[a-Z]` or one or more `ctrl-<value>` characters where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. Specifying "" will disable this feature. The default is *ctrl-p,ctrl-q*.
|
||||
|
||||
**--interactive**, **-i**
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ func (c *Container) attachToExec(streams *AttachStreams, keys string, resize <-c
|
|||
func processDetachKeys(keys string) ([]byte, error) {
|
||||
// Check the validity of the provided keys first
|
||||
if len(keys) == 0 {
|
||||
keys = define.DefaultDetachKeys
|
||||
return []byte{}, nil
|
||||
}
|
||||
detachKeys, err := term.ToBytes(keys)
|
||||
if err != nil {
|
||||
|
|
|
@ -400,17 +400,8 @@ func (r *LocalRuntime) Run(ctx context.Context, c *cliconfig.RunValues, exitCode
|
|||
}
|
||||
}
|
||||
|
||||
config, err := r.Runtime.GetConfig()
|
||||
if err != nil {
|
||||
return exitCode, err
|
||||
}
|
||||
detachKeys := c.String("detach-keys")
|
||||
if detachKeys == "" {
|
||||
detachKeys = config.DetachKeys
|
||||
}
|
||||
|
||||
// if the container was created as part of a pod, also start its dependencies, if any.
|
||||
if err := StartAttachCtr(ctx, ctr, outputStream, errorStream, inputStream, detachKeys, c.Bool("sig-proxy"), true, c.IsSet("pod")); err != nil {
|
||||
if err := StartAttachCtr(ctx, ctr, outputStream, errorStream, inputStream, c.String("detach-keys"), c.Bool("sig-proxy"), true, c.IsSet("pod")); err != nil {
|
||||
// We've manually detached from the container
|
||||
// Do not perform cleanup, or wait for container exit code
|
||||
// Just exit immediately
|
||||
|
|
Loading…
Reference in New Issue