Skip to content

Commit

Permalink
Fix: createSshDirectoryUnderHome also returns a cleanup function
Browse files Browse the repository at this point in the history
Signed-off-by: GLVS Kiriti <[email protected]>
  • Loading branch information
GLVSKiriti authored and poiana committed Apr 2, 2024
1 parent 52df26e commit 4c28e17
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions events/syscall/adding_ssh_keys_to_authorized_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ var _ = events.Register(
)

func AddingSshKeysToAuthorizedKeys(h events.Helper) error {
// Also creates .ssh directory inside tempDirectory
tempDirectoryName, err := createSshDirectoryUnderHome()
// Creates .ssh directory inside tempDirectory
sshDir, cleanup, err := createSshDirectoryUnderHome()
if err != nil {
return err
}
sshDir := filepath.Join(tempDirectoryName, ".ssh")
defer os.RemoveAll(tempDirectoryName)
defer cleanup() // Cleanup after function return

filename := filepath.Join(sshDir, "authorized_keys")
h.Log().Infof("writing to %s", filename)
Expand Down

0 comments on commit 4c28e17

Please sign in to comment.