BUGFIX: *id were not displayed correctly using -n

This commit is contained in:
yo 2022-07-01 12:12:08 +02:00
parent 54f64d9101
commit 8d87cc12c4
2 changed files with 47 additions and 47 deletions

View File

@ -650,16 +650,16 @@ func (a *Attribute32) LoadFromBinary(rdr *bufio.Reader) error {
func (a *Attribute32) Print(file *os.File, delimiter string, flags int) { func (a *Attribute32) Print(file *os.File, delimiter string, flags int) {
var user string var user string
var group string var group string
// TODO : resolve Uid and Gid (also support domain accounts)
if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER {
user = string(a.Uid) user = strconv.Itoa(int(a.Uid))
group = string(a.Gid) group = strconv.Itoa(int(a.Gid))
} else { } else {
user, _ = getUserName(a.Uid) user, _ = getUserName(a.Uid)
group, _ = getGroupName(a.Gid) 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) group, delimiter, a.Fsid, delimiter, a.Nid, delimiter, a.Dev)
if 0 == (flags & PRT_ONELINE) { if 0 == (flags & PRT_ONELINE) {
@ -711,8 +711,8 @@ func (a *Attribute64) Print(file *os.File, delimiter string, flags int) {
var group string var group string
// TODO : resolve Uid and Gid (also support domain accounts) // TODO : resolve Uid and Gid (also support domain accounts)
if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER {
user = string(a.Uid) user = strconv.Itoa(int(a.Uid))
group = string(a.Gid) group = strconv.Itoa(int(a.Gid))
} else { } else {
user, _ = getUserName(a.Uid) user, _ = getUserName(a.Uid)
group, _ = getGroupName(a.Gid) group, _ = getGroupName(a.Gid)
@ -775,11 +775,11 @@ func (s *Subject32) Print(file *os.File, delimiter string, flags int) {
var ruser string var ruser string
var rgroup string var rgroup string
if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER {
auser = string(s.Auid) auser = strconv.Itoa(int(s.Auid))
euser = string(s.Euid) euser = strconv.Itoa(int(s.Euid))
egroup = string(s.Egid) egroup = strconv.Itoa(int(s.Egid))
ruser = string(s.Ruid) ruser = strconv.Itoa(int(s.Ruid))
rgroup = string(s.Rgid) rgroup = strconv.Itoa(int(s.Rgid))
} else { } else {
auser, _ = getUserName(s.Auid) auser, _ = getUserName(s.Auid)
euser, _ = getUserName(s.Euid) euser, _ = getUserName(s.Euid)
@ -846,11 +846,11 @@ func (p *Process32) Print(file *os.File, delimiter string, flags int) {
var ruser string var ruser string
var rgroup string var rgroup string
if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER {
auser = string(p.Auid) auser = strconv.Itoa(int(p.Auid))
euser = string(p.Euid) euser = strconv.Itoa(int(p.Euid))
egroup = string(p.Egid) egroup = strconv.Itoa(int(p.Egid))
ruser = string(p.Ruid) ruser = strconv.Itoa(int(p.Ruid))
rgroup = string(p.Rgid) rgroup = strconv.Itoa(int(p.Rgid))
} else { } else {
auser, _ = getUserName(p.Auid) auser, _ = getUserName(p.Auid)
euser, _ = getUserName(p.Euid) euser, _ = getUserName(p.Euid)
@ -933,11 +933,11 @@ func (s *Subject32Ex) Print(file *os.File, delimiter string, flags int) {
var rgroup string var rgroup string
var ip string var ip string
if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER {
auser = string(s.Auid) auser = strconv.Itoa(int(s.Auid))
euser = string(s.Euid) euser = strconv.Itoa(int(s.Euid))
egroup = string(s.Egid) egroup = strconv.Itoa(int(s.Egid))
ruser = string(s.Ruid) ruser = strconv.Itoa(int(s.Ruid))
rgroup = string(s.Rgid) rgroup = strconv.Itoa(int(s.Rgid))
} else { } else {
auser, _ = getUserName(s.Auid) auser, _ = getUserName(s.Auid)
euser, _ = getUserName(s.Euid) euser, _ = getUserName(s.Euid)
@ -1026,11 +1026,11 @@ func (p *Process32Ex) Print(file *os.File, delimiter string, flags int) {
var rgroup string var rgroup string
var ip string var ip string
if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER {
auser = string(p.Auid) auser = strconv.Itoa(int(p.Auid))
euser = string(p.Euid) euser = strconv.Itoa(int(p.Euid))
egroup = string(p.Egid) egroup = strconv.Itoa(int(p.Egid))
ruser = string(p.Ruid) ruser = strconv.Itoa(int(p.Ruid))
rgroup = string(p.Rgid) rgroup = strconv.Itoa(int(p.Rgid))
} else { } else {
auser, _ = getUserName(p.Auid) auser, _ = getUserName(p.Auid)
euser, _ = getUserName(p.Euid) euser, _ = getUserName(p.Euid)
@ -1105,11 +1105,11 @@ func (s *Subject64) Print(file *os.File, delimiter string, flags int) {
var ruser string var ruser string
var rgroup string var rgroup string
if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER {
auser = string(s.Auid) auser = strconv.Itoa(int(s.Auid))
euser = string(s.Euid) euser = strconv.Itoa(int(s.Euid))
egroup = string(s.Egid) egroup = strconv.Itoa(int(s.Egid))
ruser = string(s.Ruid) ruser = strconv.Itoa(int(s.Ruid))
rgroup = string(s.Rgid) rgroup = strconv.Itoa(int(s.Rgid))
} else { } else {
auser, _ = getUserName(s.Auid) auser, _ = getUserName(s.Auid)
euser, _ = getUserName(s.Euid) euser, _ = getUserName(s.Euid)
@ -1176,11 +1176,11 @@ func (p *Process64) Print(file *os.File, delimiter string, flags int) {
var ruser string var ruser string
var rgroup string var rgroup string
if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER {
auser = string(p.Auid) auser = strconv.Itoa(int(p.Auid))
euser = string(p.Euid) euser = strconv.Itoa(int(p.Euid))
egroup = string(p.Egid) egroup = strconv.Itoa(int(p.Egid))
ruser = string(p.Ruid) ruser = strconv.Itoa(int(p.Ruid))
rgroup = string(p.Rgid) rgroup = strconv.Itoa(int(p.Rgid))
} else { } else {
auser, _ = getUserName(p.Auid) auser, _ = getUserName(p.Auid)
euser, _ = getUserName(p.Euid) euser, _ = getUserName(p.Euid)
@ -1262,11 +1262,11 @@ func (s *Subject64Ex) Print(file *os.File, delimiter string, flags int) {
var rgroup string var rgroup string
var ip string var ip string
if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER {
auser = string(s.Auid) auser = strconv.Itoa(int(s.Auid))
euser = string(s.Euid) euser = strconv.Itoa(int(s.Euid))
egroup = string(s.Egid) egroup = strconv.Itoa(int(s.Egid))
ruser = string(s.Ruid) ruser = strconv.Itoa(int(s.Ruid))
rgroup = string(s.Rgid) rgroup = strconv.Itoa(int(s.Rgid))
} else { } else {
auser, _ = getUserName(s.Auid) auser, _ = getUserName(s.Auid)
euser, _ = getUserName(s.Euid) euser, _ = getUserName(s.Euid)
@ -1355,11 +1355,11 @@ func (p *Process64Ex) Print(file *os.File, delimiter string, flags int) {
var rgroup string var rgroup string
var ip string var ip string
if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER { if PRT_NORESOLVE_USER == flags & PRT_NORESOLVE_USER {
auser = string(p.Auid) auser = strconv.Itoa(int(p.Auid))
euser = string(p.Euid) euser = strconv.Itoa(int(p.Euid))
egroup = string(p.Egid) egroup = strconv.Itoa(int(p.Egid))
ruser = string(p.Ruid) ruser = strconv.Itoa(int(p.Ruid))
rgroup = string(p.Rgid) rgroup = strconv.Itoa(int(p.Rgid))
} else { } else {
auser, _ = getUserName(p.Auid) auser, _ = getUserName(p.Auid)
euser, _ = getUserName(p.Euid) euser, _ = getUserName(p.Euid)

View File

@ -31,7 +31,7 @@ import (
) )
const ( const (
version = "0.5" version = "0.5.1"
) )
var ( var (