Skip to content

Commit

Permalink
Using temporary data by creating them and removing them after completion
Browse files Browse the repository at this point in the history
Signed-off-by: GLVS Kiriti <glvskiriti2003369@gmail.com>
  • Loading branch information
GLVSKiriti authored and poiana committed Apr 2, 2024
1 parent 3f5c815 commit 0ecd93a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions events/syscall/adding_ssh_keys_to_authorized_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,20 @@ var _ = events.Register(
)

func AddingSshKeysToAuthorizedKeys(h events.Helper) error {
const filename = "/root/.ssh/authorized_keys"
// Creates temporary data for testing.
directoryname := "/home/created-by-falco-event-generator/.ssh"
if err := os.MkdirAll(directoryname, 0755); err != nil {
return err
}

filename := directoryname + "/authorized_keys"
if err := os.WriteFile(filename, nil, os.FileMode(0755)); err != nil {
return err
}

h.Log().Infof("writing to %s", filename)
return os.WriteFile(filename, []byte("ssh-rsa <ssh_public_key>\n"), os.FileMode(0755))
err := os.WriteFile(filename, []byte("ssh-rsa <ssh_public_key>\n"), os.FileMode(0755))

defer os.RemoveAll("/home/created-by-falco-event-generator")
return err
}

0 comments on commit 0ecd93a

Please sign in to comment.