blob: d403821fd1cc6e188597640b68b31d164c45ea2c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.udp514-journal;
description = "Forward syslog from network (udp/514) to journal";
in
{
options = {
services.udp514-journal = {
enable = lib.mkEnableOption "the udp514-journal systemd socket/service";
openFirewall = lib.mkEnableOption "" // {
description = "Whether to open the port in the firewall.";
};
port = lib.mkOption {
type = lib.types.port;
default = 514;
description = "Port to listen on";
};
package = lib.mkPackageOption pkgs "udp514-journal" { };
};
};
config = lib.mkIf cfg.enable {
systemd.sockets.udp514-journal = {
enable = true;
name = "udp514-journal.socket";
inherit description;
listenDatagrams = [ (builtins.toString cfg.port) ];
wantedBy = [ "sockets.target" ];
};
systemd.services.udp514-journal = {
enable = true;
name = "udp514-journal.service";
inherit description;
requires = [
"systemd-journald.socket"
"udp514-journal.socket"
];
serviceConfig = {
Type = "notify";
Restart = "always";
ExecStart = "${cfg.package}/bin/udp514-journal";
DynamicUser = "on";
CapabilityBoundingSet = "";
AmbientCapabilities = "";
ProtectSystem = "strict";
ProtectHome = "on";
PrivateDevices = "on";
PrivateTmp = true;
PrivateUsers = "self";
PrivateNetwork = "on";
RestrictAddressFamilies = [ "AF_UNIX" ];
RestrictNamespaces = true;
RestrictSUIDSGID = true;
RestrictRealtime = true;
LockPersonality = true;
SystemCallArchitectures = "native";
SystemCallFilter = [
"@system-service"
"~@privileged"
"~@resources"
];
ProtectClock = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = "on";
ProtectControlGroups = "strict";
ProtectProc = "noaccess";
ProcSubset = "pid";
MemoryDenyWriteExecute = true;
NoNewPrivileges = true;
MemoryMax = "5M";
UMask = "0077";
};
confinement = {
enable = true;
binSh = null;
};
};
networking.firewall.allowedUDPPorts = lib.mkIf cfg.openFirewall [ cfg.port ];
};
meta.maintainers = with lib.maintainers; [ usovalx ];
}
|