-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for graceful termination #20
base: master
Are you sure you want to change the base?
Conversation
Codecov Report@@ Coverage Diff @@
## master #20 +/- ##
==========================================
- Coverage 67.04% 65.93% -1.12%
==========================================
Files 5 5
Lines 437 455 +18
==========================================
+ Hits 293 300 +7
- Misses 131 141 +10
- Partials 13 14 +1
Continue to review full report at Codecov.
|
I like the idea of this but I think we can do it without the loop condition. |
Hey @nbrownus - I'll prepare a change to remove the loop from the signal handler goroutine. What I found is that, when the socket is closed (or perhaps it's when unsetting the PID), the netlink client receives a confirmation packet, which causes the main loop to iterate once and then bail because Incidentally, I'm curious as to why there is a loop around KeepConnection(). Shouldn't it be sufficient to set the audit PID once, upon startup? |
The reason for the loop is that until recently there could only be one process listening for audit events. We had some trouble with I am hesitant about the loop condition because on a busy system it will probably become noticeable. It certainly is more readable the way you have it now though. |
Ah, I see. I think I misunderstood you originally. The reason I didn't do it that way originally is because the result would be an infinite loop once the socket is closed (which would print the Perhaps a better approach would be handling a socket close error in the main loop differently than other errors and exit the loop immediately, but this could mask an error case where the socket was closed unexpectedly (although I'm not sure how often this happens in reality). The current approach with a boolean conditional sidesteps that issue. |
@nbrownus Any thoughts? |
bump |
|
PR Summary
This change adds a signal handler that responds to SIGINT, SIGTERM, and SIGQUIT. It will unregister itself with kaudit and close the netlink socket (similar to what vanilla auditd would do). It will also cause the main event loop to end and gracefully exit with a 0 status code.
I've noticed that without this, the system console would get some error messages for the first audit log generated after go-audit exited. Setting the audit PID to 0 seems to be the way to effectively unregister the userspace process.