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

gpg module fix: already running #1732

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Vonfry
Copy link

@Vonfry Vonfry commented Aug 7, 2019

Fixes #1681, #1164

Proposed Changes

  • gpg module: Use gpgconf to get gpg-agent path instead of using environment variables and a fixed path by default, which is more compatible. For example: gpg has been started by systemd, and the sockets is set by sockets.target which is different from the default path ~/.gnugp/S.gpg-agent and no environment variable is set for current shell, but gpgconf can find the correct socket file and using it to check whether gpg-agent is already run. Otherwise, prezto will prompt gpg-agent: a gpg-agent is already running - not starting a new one at startup and it don't pick up the correct gpg-agent socket.
  • ssh module: remove re-export SSH_AUTH_SOCK in ssh module. Becasue some tools such as pam ssh auth will check socket file's permission. A link to this socket is useful but re-export the variable will break some tools.

This pr is the same as #1682 but switching into a new branch(not master).

Vonfry and others added 5 commits January 26, 2019 11:00
Fix gpg module grep regex expression, because of matching failed when `GPG_AGENT_INFO` is empty. 

And use gpgconf to get socket file instead of `$GNUPGHOME`.

fix: sorin-ionescu#1681
@belak
Copy link
Collaborator

belak commented Sep 10, 2019

Can you give me an example of tools that are broken? Isn't SSH_AUTH_SOCK needed for things like ssh-add?

@Vonfry
Copy link
Author

Vonfry commented Sep 10, 2019

@belak On my system, prezto will print gpg-agent: a gpg-agent is already running - not starting a new one. without this pr, which I don't see on other system.

SSH_AUTH_SOCK is used by many tools, but it is export by ssh automatically. In the old prezto ssh module, this variable is exported with a fixed path like ${TMPDIR:-/tmp}/ssh-agent.sock.$UID which doesn't exist on some system, such as NixOS (this system uses /var/run/$UID/xxx). I removed the repeated assignment in prezto ssh module.

@andrei-pavel
Copy link

image

Potential alternative fix

@mvcouwen
Copy link

mvcouwen commented May 5, 2020

Any progress on this PR? I seem to have the same issue when ssh-ing into a ubuntu server.

@1wilkens
Copy link

1wilkens commented May 5, 2020

I described the problem and potential solutions in #1164
EDIT: Sorry I didn't even look at the PR. It looks reasonable, however I don't know what gpgconf --list-dir agent-sock returns if no agent is running

@Vonfry Vonfry changed the title Nixos gpg module fix gpg module fix: already running May 5, 2020
@Vonfry
Copy link
Author

Vonfry commented May 5, 2020

@1wilkens gpgconf always returns the path whether gpg-agent starts or not. When not starting, it returns the path which agent creates by default.

@1wilkens
Copy link

1wilkens commented May 6, 2020

But in that case it would return ${GPG_HOME}/.gnupg/S.gpg-agent wouldn't it? The docs seem to suggest that this is the default and systemd overrides that.
So in our case that would be wrong. Not pointing fingers here, just not sure, what the "correct" solution is..

@Vonfry
Copy link
Author

Vonfry commented Jun 28, 2020

@1wilkens IMO, the one who uses prezto to startup a gpg-agent, may not want to use systemd to start it again. If systemd has started gpg-agent, gpg module in prezto will check it, and won't start again.

In the first scenario, gpgconf returns the default path which is used by prezto to create sockets.
In the secound scenario, gpgconf can find the socket created by systemd instead of a default value.

@Vonfry
Copy link
Author

Vonfry commented Jun 28, 2020

@belak Could this pr be merged? I edit the description and make it compatible on some system.

Proposed Changes:

  • gpg module: Use gpgconf to get gpg-agent path instead of using environment variables and a fixed path by default, which is more compatible. For example: gpg has been started by systemd, and the sockets is set by sockets.target which is different from the default path ~/.gnugp/S.gpg-agent and no environment variable is set for current shell, but gpgconf can find the correct socket file and use it to check whether gpg-agent is already run. Otherwise, prezto will prompt gpg-agent: a gpg-agent is already running - not starting a new one at startup and it don't pick up the correct gpg-agent socket.
  • ssh module: remove re-export SSH_AUTH_SOCK in ssh module. Becasue some tools such as pam ssh auth will check socket file's permission. A link to this socket is useful but re-export the variable will break some tools.

@tigerkzr
Copy link

tigerkzr commented Aug 26, 2023

I found the fix on another users fork but I did not see a pull request for it and they have one syntax error. What's the protocol for this? I'm new to this kind of thing, but I would like to get the fix into the system.

Edit: Never mind, it's already in this pull request. Guess it just never got merged into master

tigerkzr

This comment was marked as resolved.

@diraol
Copy link
Contributor

diraol commented Jun 3, 2024

@indrajitr or @belak can you folks take a look at this PR to see if it make sense, please? It would be nice to finally not have this message in every terminal 😃

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.

GPG module output agent already running on NixOS
7 participants