Increase width of uid field from 4 chars to 5 to allow for range of 16-bit uids.

This commit is contained in:
Karim Kanso
2020-03-10 14:17:37 +00:00
parent 497e87dea7
commit a8b29b4527
2 changed files with 10 additions and 10 deletions

View File

@@ -26,11 +26,11 @@ func (evt PSEvent) String() string {
}
if evt.PPID == -1 {
return fmt.Sprintf("UID=%-4s PID=%-6d | %s", uid, evt.PID, evt.CMD)
return fmt.Sprintf("UID=%-5s PID=%-6d | %s", uid, evt.PID, evt.CMD)
}
return fmt.Sprintf(
"UID=%-4s PID=%-6d PPID=%-6d | %s", uid, evt.PID, evt.PPID, evt.CMD)
"UID=%-5s PID=%-6d PPID=%-6d | %s", uid, evt.PID, evt.PPID, evt.CMD)
}
func NewPSScanner(ppid bool) *PSScanner {

View File

@@ -16,9 +16,9 @@ func TestRun(t *testing.T) {
events []string
}{
{pids: []int{1, 2, 3}, events: []string{
"UID=??? PID=3 | the-command",
"UID=??? PID=2 | the-command",
"UID=??? PID=1 | the-command",
"UID=??? PID=3 | the-command",
"UID=??? PID=2 | the-command",
"UID=??? PID=1 | the-command",
}},
}
@@ -423,7 +423,7 @@ func TestPSEvent(t *testing.T) {
pid: 123,
ppid: 321,
cmd: "some cmd",
expected: "UID=999 PID=123 PPID=321 | some cmd",
expected: "UID=999 PID=123 PPID=321 | some cmd",
},
{
name: "nominal-without-ppid",
@@ -431,7 +431,7 @@ func TestPSEvent(t *testing.T) {
pid: 123,
ppid: -1,
cmd: "some cmd",
expected: "UID=999 PID=123 | some cmd",
expected: "UID=999 PID=123 | some cmd",
},
{
name: "nocmd-without-ppid",
@@ -439,7 +439,7 @@ func TestPSEvent(t *testing.T) {
pid: 123,
ppid: -1,
cmd: "",
expected: "UID=999 PID=123 | ",
expected: "UID=999 PID=123 | ",
},
{
name: "nocmd-with-ppid",
@@ -447,7 +447,7 @@ func TestPSEvent(t *testing.T) {
pid: 123,
ppid: 321,
cmd: "",
expected: "UID=999 PID=123 PPID=321 | ",
expected: "UID=999 PID=123 PPID=321 | ",
},
{
name: "nouid",
@@ -455,7 +455,7 @@ func TestPSEvent(t *testing.T) {
pid: 123,
ppid: 321,
cmd: "some cmd",
expected: "UID=??? PID=123 PPID=321 | some cmd",
expected: "UID=??? PID=123 PPID=321 | some cmd",
},
}