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

Fix zsh completion for commands which output is influenced by the permissions it is run with. #2131

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kuroa-me
Copy link

This PR originates from when using nerdctl (which built its CLI with cobra), the auto-completion will not work for unprivileged users, even if they have sudo permission and are trying to tab out the command with sudo prefix.

For example, sudo nerdctl <tab> will fallback to file completion. That is because the hidden nerdctl __complete "" is run without sudo permission under the hood and fails.

This patch will enable the correct permission to be passed to the underlying hidden __complete command, thus correctly handling the case for commands which output is influenced by the permissions it is run with.

Currently, this fix is only available to zsh. And I have put it behind a switch that defaults to false.

Before

$ sudo nerdctl
completing filename
file1   file2   image1

After

$ sudo nerdctl
completing completions
apparmor    -- Manage AppArmor profiles
attach      -- Attach stdin, stdout, and stderr to a running container.
build       -- Build an image from a Dockerfile. Needs buildkitd to be runni
builder     -- Manage builds
...
$ nerdctl
completing filename
file1   file2   image1

@CLAassistant
Copy link

CLAassistant commented Apr 17, 2024

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants