Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

new wsl2-ssh-pageant.exe instance is create for every gpg communication #38

Open
davidshen84 opened this issue Mar 1, 2022 · 10 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@davidshen84
Copy link

Describe the bug
This is how I start the process in WSL 2:

setsid socat UNIX-LISTEN:$GPG_AGENT_SOCK,fork EXEC:"$HOME/.ssh/wsl2-ssh-pageant.exe --verbose --gpgConfigBasepath 'C:/Users/user-name/AppData/Local/gnupg' --gpg S.gpg-agent" >/dev/null 2>&1 &

To Reproduce
Steps to reproduce the behavior:

  1. Start a WSL 2 terminal
  2. Start the socat process like above
  3. Repeat gpg --card-status 3 times
  4. Check the wsl2-ssh-pageant.exe process in Windows Task Manager

Expected behavior

No wsl2-ssh-pageant.exe process should be found in the Task Manager

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context

  • Gpg4win v4.0.0
  • wsl2-ssh-pageant v1.4.0
@tobiaskohlbau
Copy link
Collaborator

That is actually intended, each connection attempt opens a new binary. The agent itself is not long lived. The question in this case is: why is the connection held open. The part about gpg is that it's not the main purpose of wsl2-ssh-pageant and was more or less hacked into it. As I'm not using it as my daily driver there needs to be someone who is willing to investigate that issue. Maybe I will find some time to have a look into it myself.

@davidshen84
Copy link
Author

Even if I kill the socat process in WSL, the wsl2-ssh-pageant process on the Windows side is still alive. But if I kill the gpg-agent process on the Windows side, the wsl2-ssh-pageant processes are gone.

@tobiaskohlbau
Copy link
Collaborator

Even if I kill the socat process in WSL, the wsl2-ssh-pageant process on the Windows side is still alive. But if I kill the gpg-agent process on the Windows side, the wsl2-ssh-pageant processes are gone.

I must admit that I never noticed that the wsl2-ssh-pageant proccesses are lacked behind. But I can indeed confirm it's happening for me too. I would assume there ist something in the teardown process which results in this behavior. I've tried to look into it but did not find any obvious reasons. I totally understand that this is not the expected behavior but on the other hand on most modern computers this shouldn't make a huge difference. If the computer is rebooted frequently. Nevertheless I will mark this as an issue which needs to be addressed, but I have no concrete timeframe.

@tobiaskohlbau tobiaskohlbau added bug Something isn't working help wanted Extra attention is needed labels Mar 2, 2022
@davidshen84
Copy link
Author

Well, in my case, my desktop is usually on throughout the day and went to hibernation during the night. I rarely restart or shut down my computer unless I have to.

While reading the code, I noticed you opened a connection here. But I wonder if you need to manually close it. I don't have much knowledge of go.

@davidshen84
Copy link
Author

I tried in ssh mode. I observed that the wsl2-ssh-pageant process appeared on Windows for a short time, then exited.

@FFxSquall
Copy link

@davidshen84 I download wsl2-ssh-pageant file from your repository and run 3 times gpg --card-status. wsl2-ssh-pageant.ext processes not closes

@davidshen84
Copy link
Author

davidshen84 commented Mar 29, 2022

@FFxSquall

Thanks, I just tested the one from the github artifactory and I can reproduce the issue. However, the one compiled on my local does not have this issue.

I think the real problem the the -H=windowsgui option which, according to this, creates a GUI binary. I don't think we need a GUI binary for this tool. I will update my PR to build a console binary.

Thanks

@davidshen84
Copy link
Author

@FFxSquall
Copy link

@davidshen84 It's works. Thanks

@tofupup
Copy link

tofupup commented Jul 19, 2022

@davidshen84 I've tried this on my system as well, and it appears to resolve the issue. The added Close handler doesn't seem to be called with our without the windows gui option. One note, might want to also remove the compile option from the Makefile. Much appreciated!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants