77.4. sysklogd-2.7.2
System logging daemon with built-in rotation
| Version | 2.7.2, release 1 |
| Shelf | base — The minimal userland and system daemons that every KDOS image boots with |
| Phase | 41_system (System), 197 of 1047 in build order |
| Licence | BSD-3-Clause |
| Homepage | https://github.com/troglobit/sysklogd |
| Build time | 0.1 SBU |
| Installed size | 483.3 KiB in 18 files |
| Recipe | ports/core/base/sysklogd/kpkgbuild |
About
sysklogd provides syslogd, the system log daemon. It receives the messages programs send to /dev/log and reads the kernel’s own messages itself, so there is no separate klogd, and it writes them to files under /var/log according to /etc/syslog.conf. It is KDOS’s replacement for journald (see No systemd).
/etc/init.d/22_syslog.sh starts it at boot under the ksvc supervisor, before the network comes up, with three options:
-Fkeeps it in the foreground, where the supervisor can watch it.-P /run/syslogd/syslogd.pidkeeps its own pid file beside its cache rather than loose in/run. The supervisor keeps the service’s process id in/run/kdos-svc.syslogd.pid.-8writes the bytes 0x80 to 0x9F as they arrive. Without itsyslogdwrites each asM-followed by the byte with its top bit cleared, in caret notation (0x94 becomesM-^T). Those are the bytes that follow the first byte of most UTF-8 punctuation, so an em dash leaves its first byte alone in the file, the file is no longer valid UTF-8, andgrepreportsbinary file matchesfor the whole of/var/log/messages.
The script also makes /var/log/auth.log mode 0600 before syslogd opens it: syslogd creates a missing file 0644, readable by every account, and keeps whatever mode a file has when it rotates it. Which messages go to which file is in Logs.
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/base.txt:
The logs. Without them every daemon's diagnostics go to /dev/null.
Sources
sysklogd-2.7.2.tar.gz(473.0 KiB)
sha256bc410ca64551a11fac6518b418fb6b8afbd888a70af2c5eb353334a706727bca
upstream: https://github.com/troglobit/sysklogd/releases/download/v2.7.2/sysklogd-2.7.2.tar.gz
archive copy: sources-1/base--sysklogd-2.7.2.tar.gz
Dependencies
Depends on: nothing a recipe names.
Required by: no port names it.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install sysklogd'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/base/sysklogd.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/base/sysklogd
echo 'bc410ca64551a11fac6518b418fb6b8afbd888a70af2c5eb353334a706727bca sysklogd-2.7.2.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/sysklogd
SRC=$SRC_ROOT/sysklogd-2.7.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf sysklogd-2.7.2.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--runstatedir=/run \
--disable-static \
--without-systemd \
--without-logger
make
make DESTDIR=$PKG install
install -d "$PKG/etc" "$PKG/var/log"
cat > "$PKG/etc/syslog.conf" <<'EOF'
# facility.level destination
auth,authpriv.* /var/log/auth.log
*.*;auth,authpriv.none -/var/log/messages
kern.* -/var/log/kern.log
cron.* -/var/log/cron
*.=emerg *
# Rotation is GLOBAL directives, not per-file suffixes. Writing
# `/var/log/messages rotate_size=1M` puts the path where a facility.priority
# selector belongs and syslogd answers `unknown priority name ""` for every
# such line.
rotate_size 1M
rotate_count 5
# No network socket at all. With no `listen` line syslogd otherwise opens UDP
# *:514 and accepts any host's messages into these files. 1 would keep
# forwarding to a remote `@host` action without listening; 2 is neither.
secure_mode 2
EOF
The switches, and why each is set:
--runstatedir=/run— Wheresyslogdwrites its cache,syslogd.cache, and its pid file,syslogd.pid, when-Pnames no other. The default is$localstatedir/run,/var/run, which on KDOS is a link to/run, so the switch names the directory the files actually land in.--without-systemd— Installs no systemd service file. KDOS has no systemd.--without-logger— Builds nologgerof sysklogd’s own. The util-linux port installs/usr/bin/logger, and the two would claim the same path.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/sysklogd, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf sysklogd-2.7.2-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/sysklogd, and runs the triggers its paths call for.
Contents
Installed programs: syslogd.
Installed libraries: libsyslog.so.
Installed directories: /usr/include/syslog, /usr/share/doc/sysklogd, /usr/share/licenses/sysklogd.
Short descriptions
syslogd |
log systems messages |
libsyslog.pc |
RFC5424 compliant syslogp() API and syslog() replacement from sysklogd |
Notes
The recipe writes /etc/syslog.conf itself, and its comments are what a reader of the installed file sees. Two of its rules are easy to get wrong when editing it:
- Rotation is set for every file by the global
rotate_sizeandrotate_countdirectives. A setting for one file is the action option;rotate=SIZE:COUNTafter its path; a line that starts with the path, such as/var/log/messages rotate_size=1M, puts it where afacility.priorityselector belongs, andsyslogdreportsunknown priority name ""for that line. Each file rotates at 1 MB and keeps six old copies (.0, then.1.gzto.5.gz:rotate_count 5counts the compressed ones), so nologrotatejob exists; on the live medium/var/logis in RAM, and an unbounded log would use up memory. secure_mode 2opens no network socket at all. Without it, and with nolistenline,syslogdopens UDP port 514 and writes any host’s messages into these files;secure_mode 1stops the listening but keeps forwarding to a remote@hostaction.