This commit is contained in:
yo 2023-01-16 21:30:30 +01:00
parent 9218ae6daa
commit 744f087e6c

View File

@ -412,14 +412,17 @@ func getGroupNameByGid(gid uint32) (group, error) {
func getEventName(event uint16) (string,error) {
if len(gEventDB) == 0 {
loadEventDB()
err := loadEventDB()
if err != nil {
fmt.Printf("%v\n", err)
}
}
for _, ev := range gEventDB {
if ev.Type == int(event) {
return ev.Desc, nil
}
}
return "", fmt.Errorf("Event ID not found: %x\n", event)
return "", fmt.Errorf("Event ID not found: %d\n", event)
}
// We load the entire file in memory
@ -438,15 +441,28 @@ func loadEventDB() error {
continue
}
eventStr := strings.Split(line, ":")
if len(eventStr) != 4 {
// Wait for https://github.com/openbsm/openbsm/pull/75
//if len(eventStr) != 4 {
if (len(eventStr) != 4 && eventStr[0] != "43082") || (len(eventStr) == 5 && eventStr[0] != "43082") {
continue
}
t, _ := strconv.Atoi(eventStr[0])
t, err := strconv.Atoi(eventStr[0])
if err != nil {
return fmt.Errorf("Unable to convert to int: %v\n", eventStr[0])
}
// Wait for https://github.com/openbsm/openbsm/pull/75
if t == 43082 && (len(eventStr) == 5) {
gEventDB = append(gEventDB, event{Type: t,
Name: eventStr[1],
Desc: eventStr[3],
Class: eventStr[4],})
} else {
gEventDB = append(gEventDB, event{Type: t,
Name: eventStr[1],
Desc: eventStr[2],
Class: eventStr[3],})
}
}
return nil
}
@ -521,8 +537,11 @@ func (h *Header32) Print(file *os.File, delimiter string, flags int) {
t := time.Unix((int64)(h.S), 0)
timeval = t.Format(time.UnixDate)
}
// We dont care for error
evdesc, _ := getEventName(h.E_type)
evdesc, err := getEventName(h.E_type)
if err != nil {
fmt.Printf("%v\n", err)
return
}
fmt.Fprintf(file, "header%s%d%s%d%s%s%s%v%s%s%s%d", delimiter, h.Size, delimiter, h.Version, delimiter,
//h.E_type, delimiter, h.E_mod, delimiter, t.Format(time.UnixDate), delimiter, h.Msec)
evdesc, delimiter, h.E_mod, delimiter, timeval, delimiter, h.Msec)