diff options
author | We-unite <3205135446@qq.com> | 2024-08-06 14:31:31 +0800 |
---|---|---|
committer | We-unite <3205135446@qq.com> | 2024-08-06 14:31:31 +0800 |
commit | f4655e64a1461c22ad7a3871375269915a743f40 (patch) | |
tree | 535e8d77431337bc431df85cfc2b675464395879 /src/organize.go | |
parent | 78de56b9f2d862bbdac8a02a72dd95500b7ef83e (diff) | |
download | godo-f4655e64a1461c22ad7a3871375269915a743f40.tar.gz godo-f4655e64a1461c22ad7a3871375269915a743f40.zip |
Expand connector buffer, put all file info into db
This commit I make several changes, reasons are as follows:
- Expand netlink connector buffer size. Originally it uses only one
page of mem, but sometimes it causes "no enough buffer" errno, or
the socket is blocked long time. Now it's 20 pages.
- All file infos are thrown into database. As the last commit co-
mment, There's 2 tables, "fds" and "files". When a file discriptor
is closed, the info in fds will be found, delete, and put into the
"file" table with its close time.
Left questions:
- The netlink connector is always found blocked without any reasons.
Fix it, or replace the golang-coded connector with C program? The
key is why it's blocked. Maybe it's in the kernel src code.
- sometimes audit still losts info(not too much). For instance, I
use vim in the docker to change hello.c, the hello.c may be opened
but no close info recvd. Or, the swap file of vim, such as
.hello.c.swp or .hello.c.swx is not closed. What's more, the hello.c
is never written, but swap files are. May vim write to swap files,
and replace the origin file? Let's check it.
- Besides, when a pid exits, we should check its file discriptors
and close them all.
Diffstat (limited to 'src/organize.go')
-rw-r--r-- | src/organize.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/organize.go b/src/organize.go index 238509f..5268a90 100644 --- a/src/organize.go +++ b/src/organize.go | |||
@@ -47,20 +47,21 @@ func orgnaze() { | |||
47 | break | 47 | break |
48 | } | 48 | } |
49 | rawEvent = raw.(libaudit.RawAuditMessage) | 49 | rawEvent = raw.(libaudit.RawAuditMessage) |
50 | fmt.Printf("type=%v msg=%s\n", rawEvent.Type, rawEvent.Data) | ||
50 | 51 | ||
51 | switch rawEvent.Type { | 52 | switch rawEvent.Type { |
52 | case auparse.AUDIT_SYSCALL: | 53 | case auparse.AUDIT_SYSCALL: |
53 | syscallRaw(rawEvent) | 54 | go syscallRaw(rawEvent) |
54 | case auparse.AUDIT_EXECVE: | 55 | case auparse.AUDIT_EXECVE: |
55 | execve(rawEvent) | 56 | go execve(rawEvent) |
56 | case auparse.AUDIT_CWD: | 57 | case auparse.AUDIT_CWD: |
57 | cwd(rawEvent) | 58 | go cwd(rawEvent) |
58 | case auparse.AUDIT_PATH: | 59 | case auparse.AUDIT_PATH: |
59 | path(rawEvent) | 60 | go path(rawEvent) |
60 | case auparse.AUDIT_PROCTITLE: | 61 | case auparse.AUDIT_PROCTITLE: |
61 | proctitle(rawEvent) | 62 | go proctitle(rawEvent) |
62 | case auparse.AUDIT_EOE: | 63 | case auparse.AUDIT_EOE: |
63 | eoe(rawEvent) | 64 | go eoe(rawEvent) |
64 | default: | 65 | default: |
65 | // ATTENTION: 这里也需要做防护 | 66 | // ATTENTION: 这里也需要做防护 |
66 | } | 67 | } |