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

The way of resolving user's home directory is not reliable #20

Open
hurngchunlee opened this issue May 2, 2024 · 2 comments
Open

The way of resolving user's home directory is not reliable #20

hurngchunlee opened this issue May 2, 2024 · 2 comments

Comments

@hurngchunlee
Copy link
Member

hurngchunlee commented May 2, 2024

sshDir := path.Join(homeDir, groupname, username, ".ssh")

The code above is how the .ssh/authorized_keys path is constructed. It assumes that the user's home directory follows the format of /home/{group_name}/{user_name} which is not always the case. It should be replaced by

import "os/user"
...
u, _ := user.Lookup(usename)
sshDir := path.Join(u.HomeDir, ".ssh")
@hurngchunlee
Copy link
Member Author

@RenedBruin this is the issue I mentioned to you. Just for your information.

@RenedBruin
Copy link

Also if the group doesn't exist the group is created in /home folder to be able save the file anyway which is a undesired action.

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