Skip to content

Commit

Permalink
auditd: cache new Proc objects
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo-iniguez-goya committed Mar 21, 2021
1 parent 36cdb76 commit 630e371
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions daemon/procmon/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ func FindProcess(pid int, interceptUnknown bool) *Process {
if interceptUnknown && pid < 0 {
return NewProcess(0, "")
}

if proc := findProcessInActivePidsCache(uint32(pid)); proc != nil {
return proc
}

if methodIsAudit() {
if aevent := audit.GetEventByPid(pid); aevent != nil {
audit.Lock.RLock()
Expand All @@ -103,14 +108,11 @@ func FindProcess(pid int, interceptUnknown bool) *Process {
proc.readEnv()
proc.cleanPath()

addToActivePidsCache(uint32(pid), proc)
return proc
}
}

if proc := findProcessInActivePidsCache(uint32(pid)); proc != nil {
return proc
}

linkName := fmt.Sprint("/proc/", pid, "/exe")
if _, err := os.Lstat(linkName); err != nil {
return nil
Expand Down

0 comments on commit 630e371

Please sign in to comment.