From 8d87cc12c44ecdbb8f96f41cac2de7bf18077f55 Mon Sep 17 00:00:00 2001 From: yo Date: Fri, 1 Jul 2022 12:12:08 +0200 Subject: [PATCH] BUGFIX: *id were not displayed correctly using -n --- libbsm.go | 92 +++++++++++++++++++++++++++---------------------------- main.go | 2 +- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/libbsm.go b/libbsm.go index 25d7874..dc0169e 100644 --- a/libbsm.go +++ b/libbsm.go @@ -650,16 +650,16 @@ func (a *Attribute32) LoadFromBinary(rdr *bufio.Reader) error { func (a *Attribute32) Print(file *os.File, delimiter string, flags int) { var user string var group string - // TODO : resolve Uid and Gid (also support domain accounts) + if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { - user = string(a.Uid) - group = string(a.Gid) + user = strconv.Itoa(int(a.Uid)) + group = strconv.Itoa(int(a.Gid)) } else { user, _ = getUserName(a.Uid) group, _ = getGroupName(a.Gid) } - fmt.Fprintf(file, "attribute%s%o%s%v%s%v%s%v%s%v%s%v", delimiter, a.Mode, delimiter, user, delimiter, + fmt.Fprintf(file, "attribute%s%o%s%s%s%s%s%v%s%v%s%v", delimiter, a.Mode, delimiter, user, delimiter, group, delimiter, a.Fsid, delimiter, a.Nid, delimiter, a.Dev) if 0 == (flags & PRT_ONELINE) { @@ -711,8 +711,8 @@ func (a *Attribute64) Print(file *os.File, delimiter string, flags int) { var group string // TODO : resolve Uid and Gid (also support domain accounts) if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { - user = string(a.Uid) - group = string(a.Gid) + user = strconv.Itoa(int(a.Uid)) + group = strconv.Itoa(int(a.Gid)) } else { user, _ = getUserName(a.Uid) group, _ = getGroupName(a.Gid) @@ -775,11 +775,11 @@ func (s *Subject32) Print(file *os.File, delimiter string, flags int) { var ruser string var rgroup string if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { - auser = string(s.Auid) - euser = string(s.Euid) - egroup = string(s.Egid) - ruser = string(s.Ruid) - rgroup = string(s.Rgid) + auser = strconv.Itoa(int(s.Auid)) + euser = strconv.Itoa(int(s.Euid)) + egroup = strconv.Itoa(int(s.Egid)) + ruser = strconv.Itoa(int(s.Ruid)) + rgroup = strconv.Itoa(int(s.Rgid)) } else { auser, _ = getUserName(s.Auid) euser, _ = getUserName(s.Euid) @@ -846,11 +846,11 @@ func (p *Process32) Print(file *os.File, delimiter string, flags int) { var ruser string var rgroup string if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { - auser = string(p.Auid) - euser = string(p.Euid) - egroup = string(p.Egid) - ruser = string(p.Ruid) - rgroup = string(p.Rgid) + auser = strconv.Itoa(int(p.Auid)) + euser = strconv.Itoa(int(p.Euid)) + egroup = strconv.Itoa(int(p.Egid)) + ruser = strconv.Itoa(int(p.Ruid)) + rgroup = strconv.Itoa(int(p.Rgid)) } else { auser, _ = getUserName(p.Auid) euser, _ = getUserName(p.Euid) @@ -933,11 +933,11 @@ func (s *Subject32Ex) Print(file *os.File, delimiter string, flags int) { var rgroup string var ip string if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { - auser = string(s.Auid) - euser = string(s.Euid) - egroup = string(s.Egid) - ruser = string(s.Ruid) - rgroup = string(s.Rgid) + auser = strconv.Itoa(int(s.Auid)) + euser = strconv.Itoa(int(s.Euid)) + egroup = strconv.Itoa(int(s.Egid)) + ruser = strconv.Itoa(int(s.Ruid)) + rgroup = strconv.Itoa(int(s.Rgid)) } else { auser, _ = getUserName(s.Auid) euser, _ = getUserName(s.Euid) @@ -1026,11 +1026,11 @@ func (p *Process32Ex) Print(file *os.File, delimiter string, flags int) { var rgroup string var ip string if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { - auser = string(p.Auid) - euser = string(p.Euid) - egroup = string(p.Egid) - ruser = string(p.Ruid) - rgroup = string(p.Rgid) + auser = strconv.Itoa(int(p.Auid)) + euser = strconv.Itoa(int(p.Euid)) + egroup = strconv.Itoa(int(p.Egid)) + ruser = strconv.Itoa(int(p.Ruid)) + rgroup = strconv.Itoa(int(p.Rgid)) } else { auser, _ = getUserName(p.Auid) euser, _ = getUserName(p.Euid) @@ -1105,11 +1105,11 @@ func (s *Subject64) Print(file *os.File, delimiter string, flags int) { var ruser string var rgroup string if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { - auser = string(s.Auid) - euser = string(s.Euid) - egroup = string(s.Egid) - ruser = string(s.Ruid) - rgroup = string(s.Rgid) + auser = strconv.Itoa(int(s.Auid)) + euser = strconv.Itoa(int(s.Euid)) + egroup = strconv.Itoa(int(s.Egid)) + ruser = strconv.Itoa(int(s.Ruid)) + rgroup = strconv.Itoa(int(s.Rgid)) } else { auser, _ = getUserName(s.Auid) euser, _ = getUserName(s.Euid) @@ -1176,11 +1176,11 @@ func (p *Process64) Print(file *os.File, delimiter string, flags int) { var ruser string var rgroup string if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { - auser = string(p.Auid) - euser = string(p.Euid) - egroup = string(p.Egid) - ruser = string(p.Ruid) - rgroup = string(p.Rgid) + auser = strconv.Itoa(int(p.Auid)) + euser = strconv.Itoa(int(p.Euid)) + egroup = strconv.Itoa(int(p.Egid)) + ruser = strconv.Itoa(int(p.Ruid)) + rgroup = strconv.Itoa(int(p.Rgid)) } else { auser, _ = getUserName(p.Auid) euser, _ = getUserName(p.Euid) @@ -1262,11 +1262,11 @@ func (s *Subject64Ex) Print(file *os.File, delimiter string, flags int) { var rgroup string var ip string if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { - auser = string(s.Auid) - euser = string(s.Euid) - egroup = string(s.Egid) - ruser = string(s.Ruid) - rgroup = string(s.Rgid) + auser = strconv.Itoa(int(s.Auid)) + euser = strconv.Itoa(int(s.Euid)) + egroup = strconv.Itoa(int(s.Egid)) + ruser = strconv.Itoa(int(s.Ruid)) + rgroup = strconv.Itoa(int(s.Rgid)) } else { auser, _ = getUserName(s.Auid) euser, _ = getUserName(s.Euid) @@ -1355,11 +1355,11 @@ func (p *Process64Ex) Print(file *os.File, delimiter string, flags int) { var rgroup string var ip string if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { - auser = string(p.Auid) - euser = string(p.Euid) - egroup = string(p.Egid) - ruser = string(p.Ruid) - rgroup = string(p.Rgid) + auser = strconv.Itoa(int(p.Auid)) + euser = strconv.Itoa(int(p.Euid)) + egroup = strconv.Itoa(int(p.Egid)) + ruser = strconv.Itoa(int(p.Ruid)) + rgroup = strconv.Itoa(int(p.Rgid)) } else { auser, _ = getUserName(p.Auid) euser, _ = getUserName(p.Euid) diff --git a/main.go b/main.go index 97e8219..65a54e0 100644 --- a/main.go +++ b/main.go @@ -31,7 +31,7 @@ import ( ) const ( - version = "0.5" + version = "0.5.1" ) var (