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

Using native validation if SSH-Agent is available. #21

Merged
merged 1 commit into from
Jan 15, 2022

Conversation

blaubaer
Copy link
Contributor

Instead of using just checking if SSH_AUTH_SOCK we use sshagent.Available() which also checks in more platform dependent ways if an SSH-Agent is available and working. Especially on Windows this variable is usually not present but a Pageant or Windows OpenSSH-Agent might run already. Currently you can only work with them by setting some junk into this environment variable before running the service.

Scope of change

Sorry for the whole change of the file. It seems that in the repository there was initially the files stored with crlf (as reported by git ls-files --eol). I tried several ways to clean this up, but was not successful. Although the change itself is just focused on:

Old:

// authSSHAgent discovers environment for SSH_AUTH_SOCK and builds NewSSHAgentAuth
// If returned null - no agent was set up
func authSSHAgent(params *RequestMetadataParams) (*sshGit.PublicKeysCallback, error) {
	if _, ok := os.LookupEnv("SSH_AUTH_SOCK"); !ok {
		return nil, nil
	}

New:

import (
[..]
	sshagent "github.com/xanzy/ssh-agent"
[..]
)
[..]
// authSSHAgent discovers environment for SSH_AUTH_SOCK (or other platform dependent logic)
// and builds NewSSHAgentAuth.
//
// If returned null - no agent was set up
func authSSHAgent(params *RequestMetadataParams) (*sshGit.PublicKeysCallback, error) {
	if !sshagent.Available() {
		return nil, nil
	}

Copy link
Member

@dee-kryvenko dee-kryvenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @blaubaer, thanks for the contribution! This looks great.

@dee-kryvenko dee-kryvenko merged commit 1056b2a into plumber-cd:master Jan 15, 2022
@dee-kryvenko
Copy link
Member

@blaubaer blaubaer deleted the sshagent-windows branch April 29, 2022 06:15
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.

2 participants