Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to disable detach keys #4441

Merged
merged 1 commit into from
Nov 7, 2019

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Nov 4, 2019

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

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 4, 2019
@rhatdan
Copy link
Member Author

rhatdan commented Nov 4, 2019

Fixes: #4208

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 `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. Specifying "" will disable this feature. The default is *ctrl-p,ctrl-q*.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a single character, though - it's one or more characters.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you say "[a-Z]" and then "a-z" is it all lower chars or are upper allowed too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is how the Code works. And this is how Docker was designed.

/bin/podman run -ti --detach-keys "Z" fedora  /bin/sh
sh-5.0# 
./bin/podman run -ti --detach-keys "ctrl-Z" fedora  /bin/sh
Error: invalid detach keys: Unknown character: 'ctrl-Z'
./bin/podman run -ti --detach-keys "ctrl-z" fedora  /bin/sh
sh-5.0# 

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, then I think you need to change "one of : a-z" to "one of: a-Z" or I'd prefer "one of: a-z, A-Z"

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this is safe for old containers - we might be disabling detach for every container created prior to this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, although I don't know a way around this. Is the detach-key stored somewhere? It does not get shown by podman inspect

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually after looking at the code, we don't save the detach keys anywhere. So every podman start|exec|attach will use the default keys unless overridden. We don't record the any of the following, as far as I can see

	PodmanCommand
	DetachKeys string
	Latest     bool
	NoStdin    bool
	SigProxy   bool
}

This makes the
podman create options ignored, I believe, because podman start will not use them.
Also podman run/start/create options, will not be used by podman exec, which matches what we have now, and I don't think it should block getting this in. But we could discuss whether or not these options should be recorded.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I was worried we were in a real bind here.

I'd like to get detach keys added to the DB but that sounds like another PR.

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 `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. Specifying "" will disable this feature. The default is *ctrl-p,ctrl-q*.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto previous

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is correct.

@rhatdan rhatdan force-pushed the detach branch 2 times, most recently from 275737c to 8cf5098 Compare November 5, 2019 08:59
@rhatdan
Copy link
Member Author

rhatdan commented Nov 5, 2019

/test-images

@rhatdan
Copy link
Member Author

rhatdan commented Nov 5, 2019

/test images

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>
@mheon
Copy link
Member

mheon commented Nov 6, 2019

LGTM

@rhatdan
Copy link
Member Author

rhatdan commented Nov 7, 2019

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 7, 2019
@TomSweeneyRedHat
Copy link
Member

@rhatdan you still have Format is a single character [a-Z]or one or morectrl-characters whereis one of:a-z,

So just double checking, the format can be any single upper or lower case alpha character, or it can be one or more alpha lower case characters (and other special chars)? Upper case can't be used if more than once character is used?

@openshift-merge-robot openshift-merge-robot merged commit a889fd3 into containers:master Nov 7, 2019
@rhatdan
Copy link
Member Author

rhatdan commented Nov 7, 2019

Seems to be the way that it works. Although I think it would be kind of crazy to use a single character.
I kind of liked using CTRL-z

@TomSweeneyRedHat
Copy link
Member

@rhatdan I find that really odd, but thanks for the 411. A belated LGTM then.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants