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

Feature request: --setx parameter #24

Open
lars18th opened this issue May 4, 2019 · 2 comments
Open

Feature request: --setx parameter #24

lars18th opened this issue May 4, 2019 · 2 comments

Comments

@lars18th
Copy link

lars18th commented May 4, 2019

Hi,

I'm sure that most of you are using Copy&Paste when running this nice tool. However, a simple workaround exists: The command SETX.

In windows you can use SETX SSH_AUTH_SOCK "\\.\pipe\ssh-pageant" (warning, without the equal sign) and then you have the var in your HKEY_CURRENT_USER user environment. So any program that you run/open after it will receive the var. Tip: You can unset/delete with SETX SSH_AUTH_SOCK ""

So my request is to add the parameter --setx to automatically use SETX to "share" the environment variable at starting AND unset it when finalizing.

I hope you agree! 😉

@benpye
Copy link
Owner

benpye commented May 13, 2019

This is an interesting problem 🙂

My concern with globally setting SSH_AUTH_SOCK on starting and then clearing it on exiting is that if someone happened to modify it after starting, but before closing wsl-ssh-pageant they would surprisingly have the variable cleared. I suppose before clearing we could check that it contains what we expect and deal with it as such.

That said I would be open to having the option to just update the var upon starting, though perhaps shelling out to setx isn't the most elegant method - that said the alternative of modifying the registry is hardly appealing either.

Another option, that could be cool, would be to expose the current pipe through some IPC - this would allow you to put something like $env:SSH_AUTH_SOCK=& wsl-ssh-pageant.exe --query - this is sort of how you can get the current gpg-agent socket.

@lars18th
Copy link
Author

Hi @benpye ,

Thank you for your response.

Regarding your comments...

  • My request it's about to make the --setx optional. That's execute it only if the user likes to do it.
  • Regarding the clearing of the var, perhaps it's preferable to not do it. In fact, it doesn't have sense.
  • And for the "expose the $env" this isn't a solution, beacuse the advantage of using a global environment var is that any background processes can use it. Think for example in a program that launches the native openSSH client in background to connect to some service. In this case, you can't set any env var for it... So you can only use setx.

In any case, thank you for discussing about this topic.
Regards.

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

No branches or pull requests

2 participants