aboutsummaryrefslogtreecommitdiffstats
path: root/listener/organize.go
diff options
context:
space:
mode:
authorWe-unite <3205135446@qq.com>2024-08-19 19:41:01 +0800
committerWe-unite <3205135446@qq.com>2024-08-22 14:12:01 +0800
commitf9f8f35ccd8b505a827d40f95c52ed039512b79d (patch)
tree241c393f6b865958191df802cd112f26d40dddc4 /listener/organize.go
parentae4957b41156d576e849ec0424edd4d89d8d49f2 (diff)
downloadgodo-f9f8f35ccd8b505a827d40f95c52ed039512b79d.tar.gz
godo-f9f8f35ccd8b505a827d40f95c52ed039512b79d.zip
Write documents of the program.
Add README.md on the design of the whole program, and how its every part(listener, filter) works, finally how to compile and use them. Besides, notes.md records the things and technology learned in this program, such as how to read kernel src, how the pthread_create/fork/ clone syscall works on processes and threads, the techs used to make docker container works well, and books to be read. Good good study, day day up.
Diffstat (limited to 'listener/organize.go')
-rw-r--r--listener/organize.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/listener/organize.go b/listener/organize.go
index 0c05eb4..cf6dad3 100644
--- a/listener/organize.go
+++ b/listener/organize.go
@@ -2,6 +2,7 @@ package main
2 2
3import ( 3import (
4 "fmt" 4 "fmt"
5 "io"
5 "os" 6 "os"
6 "regexp" 7 "regexp"
7 "strconv" 8 "strconv"
@@ -41,13 +42,30 @@ func orgnaze() {
41 var raw interface{} 42 var raw interface{}
42 var rawEvent libaudit.RawAuditMessage 43 var rawEvent libaudit.RawAuditMessage
43 44
45 var diagWriter io.Writer
46 var f *os.File
47 var err error
48 var fileName string
49 if *diag != "" {
50 fileName = *diag
51 } else {
52 fileName = "godo.log"
53 }
54
55 f, err = os.OpenFile(fileName, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0o664)
56 if err != nil {
57 f = nil
58 }
59 defer f.Close()
60 diagWriter = f
61
44 for { 62 for {
45 raw, ok = <-rawChan 63 raw, ok = <-rawChan
46 if !ok { 64 if !ok {
47 break 65 break
48 } 66 }
49 rawEvent = raw.(libaudit.RawAuditMessage) 67 rawEvent = raw.(libaudit.RawAuditMessage)
50 // fmt.Printf("type=%v msg=%s\n", rawEvent.Type, rawEvent.Data) 68 fmt.Fprintf(diagWriter, "type=%v msg=%s\n", rawEvent.Type, rawEvent.Data)
51 69
52 switch rawEvent.Type { 70 switch rawEvent.Type {
53 case auparse.AUDIT_SYSCALL: 71 case auparse.AUDIT_SYSCALL: