Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/c-blake/kslog

Minimalistic Kernel-Syslogd For Linux in Nim
https://github.com/c-blake/kslog

Last synced: 5 days ago
JSON representation

Minimalistic Kernel-Syslogd For Linux in Nim

Awesome Lists containing this project

README

        

Privilege and Complexity
========================
I mostly wrote this because I wanted to run my kernel/system logger not as
root. I looked into doing this with `syslog-ng` and it seemed hard to get
right. `CAP_SYS_ADMIN` or whatnot also seem used. I had a hunch that over
the years feature bloat had exploded sysloggers beyond reason making what I
wanted unnecessarily difficult. For what most people use it for, it should
really be a simple program anyway. syslog-ng is over 300,000 lines of C.
Even busybox syslogd clocks in at over 1,000 lines.

Instead of all that jazz, I give you `kslog` - under 200 lines of Nim that
likely does all you really need in two easy pieces - a few dozen line easily
audited privileged `kslog_open.nim` and 125-ish line `kslog.nim`.

Sadly, `kslog-open` (*not* `kslog`) must run as root to manipulate `/dev/`.
At this late date, there is probably no relocating of `/dev/log` or making
binding of Unix domain sockets easier. This opening phase is *all* `kslog`
needs elevated privilege for. `kslog-open` just does this minimal work to
set up input file descriptors 0,3 and then drops privilege & exec's `kslog`.
`kslog` itself only needs permission to open its output files for write.
If said output files already exist with `syslog`-user writable permission,
the `syslog` user need not even have permission to create new files in
`/var/log`. Wide ability to write to `/dev/log` always affords an easy
fill-the-disk attack, of course.

Log Contents
=============
Priority & facility numbers are retained in `kslog` logs. I doubt there is a
better way to learn how to filter out informational|debug messages by altering
`maxLevel` than looking at a big list of examples. `grep '\