Skip to content

Commit 7927751

Browse files
authored
Merge pull request #147 from ssahani/fix/ci-packaging
Fix CI, add packaging, update docs
2 parents abe4952 + 06bdb9a commit 7927751

1 file changed

Lines changed: 116 additions & 18 deletions

File tree

README.md

Lines changed: 116 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ sending logs when the network is up and stops when it goes down
2222
- **Standard formats** — RFC 5424 (recommended), RFC 3164 (legacy BSD syslog)
2323
- **Smart filtering** — exclude sensitive facilities (auth/authpriv) and log levels
2424
- **Namespace support** — forward from specific journal namespaces or aggregate all
25-
- **Hardened** — runs as unprivileged user with restricted capabilities
25+
- **Structured data** — attach metadata to messages or extract from journal fields
26+
- **Hardened** — runs as unprivileged user with systemd security sandboxing
2627
- **Fault tolerant** — automatic reconnection with cursor persistence ensures no message loss
28+
- **Lightweight** — minimal memory footprint, no runtime dependencies beyond systemd and OpenSSL
2729

2830
## Quick Start
2931

@@ -54,12 +56,12 @@ journalctl -u systemd-netlogd -f
5456
| Distribution | Command |
5557
|----------------|-------------------------------------|
5658
| Ubuntu/Debian | `sudo apt install systemd-netlogd` |
57-
| Fedora | Available via COPR repositories |
59+
| Fedora/RHEL | Available via COPR repositories |
5860
| Arch Linux | AUR: `yay -S systemd-netlogd-git` |
5961

6062
### Build from Source
6163

62-
**Prerequisites:** systemd >= 230 (v255+ recommended), meson, gperf, libcap, OpenSSL
64+
**Prerequisites:** systemd >= 230 (v255+ recommended), meson (>= 0.51), gperf, libcap, OpenSSL
6365

6466
```bash
6567
# Install dependencies (Debian/Ubuntu)
@@ -68,6 +70,9 @@ sudo apt install build-essential meson gperf libcap-dev libsystemd-dev libssl-de
6870
# Install dependencies (Fedora/RHEL)
6971
sudo dnf install gcc meson gperf libcap-devel systemd-devel openssl-devel libcmocka-devel
7072

73+
# Install dependencies (Arch Linux)
74+
sudo pacman -S base-devel meson gperf libcap openssl cmocka
75+
7176
# Build
7277
git clone https://github.com/systemd/systemd-netlogd.git
7378
cd systemd-netlogd
@@ -86,6 +91,14 @@ sudo systemctl daemon-reload
8691
sudo systemctl enable --now systemd-netlogd
8792
```
8893

94+
### Packaging
95+
96+
The repository includes packaging for multiple distributions:
97+
98+
- **RPM**`systemd-netlogd.spec` (Fedora, RHEL, Rocky Linux)
99+
- **DEB**`debian/` directory (Ubuntu, Debian)
100+
- **Arch Linux**`PKGBUILD`
101+
89102
## Configuration
90103

91104
Configuration file: `/etc/systemd/netlogd.conf`
@@ -118,7 +131,7 @@ Reload after changes: `sudo systemctl reload systemd-netlogd`
118131
| `ExcludeSyslogFacility=` | Space-separated facility list to exclude | None |
119132
| `ExcludeSyslogLevel=` | Space-separated level list to exclude | None |
120133

121-
**Facilities:** `kern`, `user`, `mail`, `daemon`, `auth`, `syslog`, `lpr`, `news`, `uucp`, `cron`, `authpriv`, `ftp`, `ntp`, `security`, `console`, `solaris-cron`, `local0``local7`
134+
**Facilities:** `kern`, `user`, `mail`, `daemon`, `auth`, `syslog`, `lpr`, `news`, `uucp`, `cron`, `authpriv`, `ftp`, `ntp`, `security`, `console`, `solaris-cron`, `local0`-`local7`
122135

123136
**Levels:** `emerg`, `alert`, `crit`, `err`, `warning`, `notice`, `info`, `debug`
124137

@@ -143,14 +156,50 @@ NoDelay=yes
143156
ExcludeSyslogFacility=auth authpriv
144157
```
145158

159+
**DTLS (encrypted UDP):**
160+
```ini
161+
[Network]
162+
Address=192.168.1.100:4433
163+
Protocol=dtls
164+
TLSCertificateAuthMode=warn
165+
```
166+
167+
**TCP with filtering:**
168+
```ini
169+
[Network]
170+
Address=192.168.1.100:514
171+
Protocol=tcp
172+
ExcludeSyslogFacility=auth authpriv
173+
ExcludeSyslogLevel=debug
174+
```
175+
146176
**Cloud service (Papertrail):**
147177
```ini
148178
[Network]
149179
Address=logs7.papertrailapp.com:12345
150180
Protocol=tls
181+
LogFormat=rfc5424
182+
TLSCertificateAuthMode=deny
183+
KeepAlive=yes
184+
```
185+
186+
**Cloud service (Loggly):**
187+
```ini
188+
[Network]
189+
Address=logs-01.loggly.com:6514
190+
Protocol=tls
191+
LogFormat=rfc5424
192+
StructuredData=[YOUR-CUSTOMER-TOKEN@41058]
193+
TLSCertificateAuthMode=deny
194+
```
195+
196+
**Multicast:**
197+
```ini
198+
[Network]
199+
Address=239.0.0.1:6000
151200
```
152201

153-
**With structured data:**
202+
**With structured data and message IDs:**
154203
```ini
155204
[Network]
156205
Address=192.168.1.100:514
@@ -161,8 +210,52 @@ UseSysLogStructuredData=yes
161210
UseSysLogMsgId=yes
162211
```
163212

213+
**All journal namespaces:**
214+
```ini
215+
[Network]
216+
Address=192.168.1.100:514
217+
Protocol=tcp
218+
Namespace=*
219+
```
220+
164221
See the [`examples/`](examples/) directory for more production-ready configurations.
165222

223+
## Security
224+
225+
systemd-netlogd runs with minimal privileges via systemd hardening:
226+
227+
- Runs as dedicated `systemd-journal-netlog` user (not root)
228+
- `ProtectSystem=strict`, `ProtectHome=yes`, `PrivateTmp=yes`
229+
- `ProtectKernelTunables=yes`, `ProtectKernelModules=yes`, `ProtectKernelLogs=yes`
230+
- `MemoryDenyWriteExecute=yes`, `LockPersonality=yes`
231+
- `SystemCallArchitectures=native`, `PrivateDevices=yes`
232+
233+
Audit the security posture:
234+
```bash
235+
sudo systemd-analyze security systemd-netlogd.service
236+
```
237+
238+
Best practices:
239+
- Use `Protocol=tls` for forwarding over untrusted networks
240+
- Set `TLSCertificateAuthMode=deny` with a valid CA certificate in production
241+
- Exclude sensitive logs: `ExcludeSyslogFacility=auth authpriv`
242+
243+
See [SECURITY.md](SECURITY.md) for the full security policy and vulnerability reporting.
244+
245+
## Signals
246+
247+
| Signal | Action |
248+
|--------|--------|
249+
| `SIGTERM`, `SIGINT` | Graceful shutdown, save cursor state |
250+
| `SIGUSR1` | Toggle debug log level |
251+
| `SIGUSR2` | Reserved |
252+
253+
```bash
254+
# Enable debug logging temporarily
255+
sudo kill -SIGUSR1 $(pidof systemd-netlogd)
256+
journalctl -u systemd-netlogd -f
257+
```
258+
166259
## Troubleshooting
167260

168261
```bash
@@ -177,10 +270,7 @@ nc -u -vz remote-server 514 # UDP
177270
# Generate test log
178271
logger -p user.info "Test from systemd-netlogd"
179272

180-
# Enable debug logging temporarily
181-
sudo kill -SIGUSR1 $(pidof systemd-netlogd)
182-
183-
# Or persistently via systemd override
273+
# Enable persistent debug logging
184274
sudo systemctl edit systemd-netlogd
185275
# Add: Environment=SYSTEMD_LOG_LEVEL=debug
186276

@@ -193,16 +283,24 @@ sudo rm /var/lib/systemd-netlogd/state
193283
sudo systemctl start systemd-netlogd
194284
```
195285

286+
## State Persistence
287+
288+
The daemon saves its journal cursor to `/var/lib/systemd-netlogd/state` after each
289+
successful forward. This ensures no message loss across restarts or network outages.
290+
On startup, it resumes from the last saved position.
291+
196292
## Documentation
197293

198-
- **[Man page](doc/index.rst)** — full reference (`man systemd-netlogd`)
199-
- **[FAQ](FAQ.md)** — common questions and answers
200-
- **[ARCHITECTURE.md](ARCHITECTURE.md)** — internal design and data flow
201-
- **[TESTING.md](TESTING.md)** — test suite and validation guide
202-
- **[CONTRIBUTING.md](CONTRIBUTING.md)** — development setup and contribution guide
203-
- **[SECURITY.md](SECURITY.md)** — security policy and vulnerability reporting
204-
- **[CHANGELOG.md](CHANGELOG.md)** — release history
205-
- **[examples/](examples/)** — production-ready configuration examples
294+
| Document | Description |
295+
|----------|-------------|
296+
| [Man page](doc/index.rst) | Full reference (`man systemd-netlogd`) |
297+
| [FAQ](FAQ.md) | Common questions and answers |
298+
| [ARCHITECTURE.md](ARCHITECTURE.md) | Internal design and data flow |
299+
| [TESTING.md](TESTING.md) | Test suite and validation guide |
300+
| [CONTRIBUTING.md](CONTRIBUTING.md) | Development setup and contribution guide |
301+
| [SECURITY.md](SECURITY.md) | Security policy and vulnerability reporting |
302+
| [CHANGELOG.md](CHANGELOG.md) | Release history |
303+
| [examples/](examples/) | Production-ready configuration examples |
206304

207305
## Contributing
208306

@@ -218,7 +316,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for the full guide.
218316

219317
## License
220318

221-
LGPL-2.1-or-later same license as systemd. See [LICENSE.LGPL2.1](LICENSE.LGPL2.1).
319+
LGPL-2.1-or-later -- same license as systemd. See [LICENSE.LGPL2.1](LICENSE.LGPL2.1).
222320

223321
## Author
224322

0 commit comments

Comments
 (0)