-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Image signing fails with hardware gpg key #23659
Comments
Although I've just found out about #16406 which makes signing process not very practical anyway... |
In general rootless podman runs in a user namespace where we are mapped as root so if we execute other binaries the logically assume they run as root (uid 0). For containers we have something like cc @mtrmac |
It might be possible but it seems non-trivial to me. From Podman’s point of view, the signing happens as a part of push operation in c/common/libimage — and I think we do need to run at least the c/storage accesses in the typical user namespace (depending on details of the graph driver and specific filesystem backend, but at least in the fallback “naive diff” implementation). c/storage is, I think, not set up to specifically identify / isolate the parts that need user namespace from the rest; that would require a detailed codebase audit. If the suggestion is to run in the typical user namespace, but only to run the signing process in a nested more specialized ID mapping environment: c/image probably shouldn’t know the details, but passing, as an option, a function to use for all subprocess creations instead of the standard-library … in practice, here, the GPG subprocesses are executed by a C library libgpgme, so we just don’t have that kind of control; we would have to introduce an extra IPC layer from podman+c/image to our own single-use GPG server running in a modified namespace, which then further uses libgpgme to run GPG subprocesses. I’m also worried that such a nested-user-namespace setup could have other unexpected effects: the GPG agent is, typically, an user-account-shared resource, potentially (as in here) started on-demand on the first use, so we could create an agent in an unusual/unexpected namespace configuration and affect all future non-Podman operations. And if we are talking about smart cards and other non-plain-vanilla setups, I’m a single UID/GID mapping might not be sufficient to replicate all the expectations of that software. It would be far better to start the agent from outside of Podman’s namespaces, and let the signing only trigger a request. Would it work for the caller to explicitly specify GNUPGHOME? Looking at https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob;f=common/homedir.c;h=392910867feb5cc0296ec0b34b5c3404eb017fc9;hb=refs/heads/master#l1416, that might be a workaround. Podman already manipulates |
Note that |
Right this is what I was thinking, if we do not directly execute these commands anyway then the extra work is certainly high.
Well we already execute it from within the podman userns today, with very few exceptions podman always runs in the user namespace and of course there is no way to unjoin it thus my suggest to at least somehow fix the id mappings so I don't think it would make things any worse. But yes whenever the result will be any better I am not sure either. |
A friendly reminder that this issue had no activity for 30 days. |
Any chance of fixing this? cd ~/.gnupg
for i in S.gpg-agent.ssh S.gpg-agent.extra S.gpg-agent.browser S.gpg-agent S.scdaemon; do
ln -s "${XDG_RUNTIME_DIR}/gnupg/$i" "$i";
done |
Issue Description
I use YubiKey for GPG and when trying to sign image during
podman push --sign-by
it fails to locate card. Nowadays GnuPG has agent socket located in$XDG_RUNTIME_DIR/gnupg
directory, which usually translates to/run/user/<uid>/gnupg
. It appears thatpodman push
uses user namespace by default so it tries looking up/run/user/0/gnupg
and fails. This ultimately leads to startup of anothergpg-agent
instance (with socket in$HOME/.gnupg
due to permission issues in/run/user
) and the new instance fails to lookup card. If symlink is created temporarily/run/user/0 -> /run/user/<uid>
signing works fine.Steps to reproduce the issue
Steps to reproduce the issue
gpg-agent
running and having socket in$XDG_RUNTIME_DIR/gnupg
Describe the results you received
New
gpg-agent
instance is started.Describe the results you expected
Already running
gpg-agent
instance should be used.podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
Yes
Additional environment details
Additional environment details
Additional information
Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting
The text was updated successfully, but these errors were encountered: