Skip to content

Commit

Permalink
created a directory and syslog file inside it
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 4, 2024
1 parent c04f57d commit a973e7a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions events/syscall/clear_log_activities.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@ import (
var _ = events.Register(ClearLogActivites)

func ClearLogActivites(h events.Helper) error {
// Opening a file from access log files list with O_TRUNC flag
filename := "/var/log/syslog"
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_TRUNC, 0644)
if err != nil {
h.Log().WithError(err).Error("Error opening file")
filename := "/created-by-event-generator/syslog"

if err := os.Mkdir("/created-by-event-generator", 0755); err != nil {
h.Log().WithError(err).Error("Error creating directory")
return err
}
defer file.Close()
defer os.RemoveAll("/created-by-event-generator")

// Perform some write operation on the file
_, err = file.WriteString("Created by falco event generator")
// Open or create the file with write-only access and truncate its contents if it exists
file, err := os.OpenFile(filename, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
if err != nil {
h.Log().WithError(err).Error("Error writing into file")
h.Log().WithError(err).Error("Error opening file")
return err
}
defer file.Close()

h.Log().Info("Log file: ", filename, "was tampered.")
return nil
}

0 comments on commit a973e7a

Please sign in to comment.