main
nix 69 lines 2.45 KB
Raw
1 { config, pkgs, ... }:
2
3 {
4 systemd.services.ofborg-log-message-collector = {
5 description = "ofBorg log message collector";
6
7 wantedBy = [ "ofborg.target" ];
8 bindsTo = [ "ofborg.target" ];
9 restartTriggers = [ config.environment.etc."ofborg.json".source ];
10
11 stopIfChanged = false;
12 unitConfig.StartLimitIntervalSec = 0;
13 serviceConfig = {
14 # Filesystem stuff
15 ProtectSystem = "strict"; # Prevent writing to most of /
16 ProtectHome = true; # Prevent accessing /home and /root
17 PrivateTmp = true; # Give an own directory under /tmp
18 PrivateDevices = true; # Deny access to most of /dev
19 ProtectKernelTunables = true; # Protect some parts of /sys
20 ProtectControlGroups = true; # Remount cgroups read-only
21 RestrictSUIDSGID = true; # Prevent creating SETUID/SETGID files
22 PrivateMounts = true; # Give an own mount namespace
23 RemoveIPC = true;
24 UMask = "0027";
25
26 Restart = "always";
27 RestartSec = "5s";
28 ExecStart = "${pkgs.ofborg}/bin/log-message-collector /etc/ofborg.json";
29 User = "ofborg-logs";
30 Group = "ofborg-logs";
31
32 LogsDirectory = "ofborg";
33
34 # Capabilities
35 CapabilityBoundingSet = ""; # Allow no capabilities at all
36 NoNewPrivileges = true; # Disallow getting more capabilities. This is also implied by other options.
37
38 # Kernel stuff
39 ProtectKernelModules = true; # Prevent loading of kernel modules
40 SystemCallArchitectures = "native"; # Usually no need to disable this
41 ProtectKernelLogs = true; # Prevent access to kernel logs
42 ProtectClock = true; # Prevent setting the RTC
43
44 # Misc
45 LockPersonality = true; # Prevent change of the personality
46 ProtectHostname = true; # Give an own UTS namespace
47 RestrictRealtime = true; # Prevent switching to RT scheduling
48 MemoryDenyWriteExecute = true; # Maybe disable this for interpreters like python
49 PrivateUsers = true; # If anything randomly breaks, it's mostly because of this
50 RestrictNamespaces = true;
51 SystemCallFilter = "@system-service";
52 };
53 };
54
55 users.users.ofborg-logs = {
56 isSystemUser = true;
57 group = "ofborg-logs";
58 description = "ofBorg logs user";
59 };
60 users.groups.ofborg-logs = { };
61
62 sops.secrets = {
63 "ofborg/log-message-collector-rabbitmq-password" = {
64 owner = "ofborg-logs";
65 restartUnits = [ "ofborg-log-message-collector.service" ];
66 sopsFile = ../../secrets/ofborg.core01.ofborg.org.yml;
67 };
68 };
69 }