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

specify ssh dir #2981

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

Conversation

JoelLau
Copy link

@JoelLau JoelLau commented Oct 28, 2024

override default ~/.ssh/ directory for ssh paths

@JoelLau
Copy link
Author

JoelLau commented Oct 28, 2024

@dominikschulz i realise this doesn't exactly implement the features described in #2933, but would this be a step in the right direction?

Copy link
Member

@AnomalRoil AnomalRoil left a comment

Choose a reason for hiding this comment

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

While it's not a flag, I think a env variable for that is actually more sensible.

A test would be nice too.

internal/backend/crypto/age/ssh.go Outdated Show resolved Hide resolved
internal/backend/crypto/age/ssh.go Outdated Show resolved Hide resolved
internal/backend/crypto/age/ssh.go Outdated Show resolved Hide resolved
@JoelLau JoelLau marked this pull request as draft October 30, 2024 04:42
@JoelLau JoelLau marked this pull request as ready for review October 30, 2024 13:12
@JoelLau
Copy link
Author

JoelLau commented Oct 31, 2024

@AnomalRoil are there any other changes required for this PR?

@JoelLau
Copy link
Author

JoelLau commented Nov 4, 2024

if its not too much trouble, can i get this PR accepted for hacktoberfest by merging this pr or marking it with the hacktoberfest-accepted label?

func getSSHDir() (string, error) {
preferredPath := os.Getenv("GOPASS_SSH_DIR")
sshDir := filepath.Join(preferredPath, ".ssh")
if fsutil.IsDir(sshDir) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we should also check if preferredPath is not empty here. Otherwise we might end up with .ssh (i.e. .ssh in the current pwd) w/o users asking for it.

Copy link
Author

Choose a reason for hiding this comment

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

thanks @dominikschulz , i've added the check

func getSSHDir() (string, error) {
preferredPath := os.Getenv("GOPASS_SSH_DIR")
sshDir := filepath.Join(preferredPath, ".ssh")
if fsutil.IsDir(sshDir) && sshDir != "" {
Copy link
Member

Choose a reason for hiding this comment

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

This should actually check if prefrerredPath is empty. Otherwise we might still pick up a .ssh dir does exist in the current pwd.

Signed-off-by: Joel Lau <[email protected]>
func getSSHDir() (string, error) {
preferredPath := os.Getenv("GOPASS_SSH_DIR")
sshDir := filepath.Join(preferredPath, ".ssh")
if fsutil.IsDir(sshDir) && preferredPath != "" {
Copy link
Member

Choose a reason for hiding this comment

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

Could you swap both conditions?
os.Getenv is most likely to return an empty string for most users in most of the case, so let's not run IsDir if we don't need to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants