-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathco2mon2pg.service
93 lines (69 loc) · 2.33 KB
/
co2mon2pg.service
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
[Unit]
Description=Spool USB CO2 data to Postgres
Documentation=https://github.com/gsauthof/co2mon2pg
After=network.target postgresql.service
[Service]
User=metricsdb
Group=metricsdb
Type=notify
EnvironmentFile=-/etc/sysconfig/co2mon2pg
ExecStart=/usr/local/bin/co2mon2pg --systemd $OPTIONS
# Restart the service if it exited cleanly/dirty/because of a signal/timeout
Restart=always
# Sleep X seconds between a Restart= triggered restart
RestartSec=119
# NB: On a SELinux enabled system we are running this service
# unconfined since no domain transition is defined
# for the executable's default label.
# However, below systemd settings sandbox the process.
# no new privileges via exec setuid etc.
NoNewPrivileges=true
# We need access to the HID device ...
#PrivateDevices=true
DeviceAllow=char-usb_device
# Need shared /tmp for Postgres unix-domain-socket
#PrivateTmp=true
# Mount all system directories read-only except for /dev|/proc|/sys|/tmp
# NOTE: Not available on CentOS 7 - but on e.g. Fedora 29
ProtectSystem=strict
# Make /home|/root|/run/user inaccessible/empty
ProtectHome=true
# Can't disable the clock because this breaks opening the HID device?!?
#ProtectClock=true
ProtectHostname=true
ProtectKernelTunables=true
ProtectKernelModules=true
# disallow reading/writing kernel ring buffer
ProtectKernelLogs=true
# disallow modifying control groups
ProtectControlGroups=true
ProtectProc=invisible
# many services need to read _some_thing from /proc/ but this one doesn't
ProcSubset=pid
SystemCallArchitectures=native
# does work:
SystemCallFilter=@system-service
# deny-list, i.e. remove some of the @system-service elements
SystemCallFilter=~@keyring @memlock @privileged @resources @setuid userfaultfd
# unless co2mond is used
SystemCallFilter=~@process
# python calls prctl, hidapi lib is multi-threaded
SystemCallFilter=prctl clone clone3
SystemCallFilter=~@ipc
RemoveIPC=true
# assign the empty set
CapabilityBoundingSet=
# we just need a UDS to Postgres
# overkill, since AF_INET* are blacklisted
IPAddressDeny=any
RestrictAddressFamilies=AF_UNIX AF_NETLINK
RestrictNamespaces=true
# kind of implied by User=/NoNewPrivileges= setting
RestrictRealtime=true
RestrictSUIDSGID=true
# not possible since hidapi lib requires AF_NETLINK
#PrivateNetwork=true
MemoryDenyWriteExecute=true
UMask=0077
[Install]
WantedBy=multi-user.target