Skip to content

Add systemd unit + install target - issue #20 - #26

Merged
Crank-Git merged 5 commits into
devfrom
feature/systemd-install
Oct 25, 2026
Merged

Crank-Git merged 5 commits into
devfrom
feature/systemd-install

Conversation

@Crank-Git

Copy link
Copy Markdown
Owner

issue #20: systemd unit + install target

sourceknock is a root daemon with no service unit, so users had to figure out
how to run and supervise it by hand. This adds a systemd unit (plus a
per-instance template) and a make install / make uninstall path.

What's here

  • contrib/systemd/sourceknock.service - runs the daemon as the
    unprivileged sourceknock user, granted only CAP_NET_RAW +
    CAP_NET_ADMIN (not root), logs to journald, Restart=on-failure.
  • contrib/systemd/sourceknock@.service - template unit;
    systemctl start sourceknock@myconf runs /etc/sourceknock/myconf.conf.
  • Makefile - make install / make uninstall place the binary and units
    (overridable PREFIX/BINDIR/SYSDIR/CONFDIR, DESTDIR-aware) and
    reload systemd.
  • README - documents direct run + systemd install / enable / disable.

Notes

  • The units hardcode the sourceknock user (standard for static unit files);
    the README shows how to create that system user. make install needs root.
  • Validated the units as well-formed INI and confirmed make test is still
    green. Full install/enable was not exercised (no systemd on this host).

Add a libFuzzer target for packet.c's untrusted frame parser, which reads
variable-length Ethernet/IPv6 headers and walks a bounded IPv6 extension
header chain - classic out-of-bounds-read territory.

- tests/fuzz/fuzz_pkt_parse.cc: LLVMFuzzerTestOneInput feeds arbitrary
  bytes to pkt_parse(); first byte selects the link layer so both the
  Ethernet-II and loopback entry paths are exercised.
- tests/fuzz/seed_check.c: plain-C smoke runner that drives every seed
  through pkt_parse (libFuzzer's runtime isn't on every host).
- tests/fuzz/make_seeds.py + corpus/pkt_parse/: 12 seeds covering IPv4,
  IPv6, the fragment (nh=44) and multi extension-header walks, loopback,
  and truncated/garbage frames.
- Makefile: `make fuzz-build` / `make fuzz` (clang, -fsanitize=fuzzer,
  address, 60s bound) and `make fuzz-seeds`.
- ci.yml: bounded fuzz run on ubuntu (Linux-only: libFuzzer runtime).

Also fixes a real bug surfaced by the fragment seed: ipv6_l4() read the
Fragment header's Next Header at offset +6, but per RFC 8200 it is at
offset 0, so any IPv6 fragment-encapsulated packet was silently dropped.
@Crank-Git
Crank-Git force-pushed the feature/systemd-install branch from f230345 to 34f693e Compare October 25, 2026 05:05
@Crank-Git
Crank-Git force-pushed the feature/systemd-install branch from 34f693e to 7e0ebc4 Compare October 25, 2026 05:48
pkt_parse() read buf[ip_off] without checking ip_off < len. A 14-byte
Ethernet frame (dst+src+ethertype 0x0800, no L3 payload) passed the
'len < 14' guard, then buf[14] read one byte past the end -> ASan
heap-buffer-overflow under libFuzzer.

Add an 'ip_off >= len -> return 0' guard covering both link layers, and a
regression seed (header_only_ipv4.eth). Also reformat the extern "C"
wrapper in fuzz_pkt_parse.cc to Allman style so make check-format passes.
Ship a systemd unit and a per-instance template so sourceknock can be run
and supervised the standard way instead of by hand.

- contrib/systemd/sourceknock.service: runs the daemon as the unprivileged
  'sourceknock' user, granted only CAP_NET_RAW + CAP_NET_ADMIN (not root),
  logs to journald, restarts on failure.
- contrib/systemd/sourceknock@.service: template unit;
  'sourceknock@myconf' runs /etc/sourceknock/myconf.conf.
- Makefile: 'make install' / 'make uninstall' place the binary and units
  (overridable PREFIX/BINDIR/SYSDIR/CONFDIR, DESTDIR-aware) and reload systemd.
- README: documents direct run + systemd install/enable/disable.

Units validated as well-formed INI; 'make test' still green.
The systemd install target was inserted over the explicit %.o: %.c rule,
leaving make to fall back to its built-in implicit rule (no -Isrc), which
broke header resolution for src/*.o and the test objects. Restores the rule
so make test is green again.
@Crank-Git
Crank-Git force-pushed the feature/systemd-install branch from 7e0ebc4 to a237b84 Compare October 25, 2026 05:56
@Crank-Git
Crank-Git merged commit 9f1beb2 into dev Oct 25, 2026
3 checks passed
@Crank-Git Crank-Git mentioned this pull request Oct 25, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant