Skip to content

Commit 982692f

Browse files
committed
Add systemd service unit file
Installs to /lib/systemd/system/. Includes security hardening directives: NoNewPrivileges, ProtectSystem=strict, PrivateTmp, PrivateDevices, MemoryDenyWriteExecute, and others.
1 parent 18e9c00 commit 982692f

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CFLAGS += -Wall -Wextra -Werror -pedantic -std=c99
55
PREFIX ?= /usr/local
66
BINDIR ?= $(PREFIX)/bin
77
MANDIR ?= $(PREFIX)/share/man
8+
UNITDIR ?= /lib/systemd/system
89

910
all: thinproxy
1011

@@ -16,10 +17,13 @@ install: thinproxy
1617
install -m 755 thinproxy $(DESTDIR)$(BINDIR)/
1718
install -d $(DESTDIR)$(MANDIR)/man8
1819
install -m 644 thinproxy.8 $(DESTDIR)$(MANDIR)/man8/
20+
install -d $(DESTDIR)$(UNITDIR)
21+
install -m 644 thinproxy.service $(DESTDIR)$(UNITDIR)/
1922

2023
uninstall:
2124
rm -f $(DESTDIR)$(BINDIR)/thinproxy
2225
rm -f $(DESTDIR)$(MANDIR)/man8/thinproxy.8
26+
rm -f $(DESTDIR)$(UNITDIR)/thinproxy.service
2327

2428
clean:
2529
rm -f thinproxy

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ The default prefix is `/usr/local`. Override with:
4141
make install PREFIX=/usr DESTDIR=/tmp/pkg
4242
```
4343

44+
A systemd unit file is installed to `/lib/systemd/system/`. To enable:
45+
46+
```sh
47+
sudo systemctl daemon-reload
48+
sudo systemctl enable --now thinproxy
49+
```
50+
4451
## Usage
4552

4653
```

thinproxy.service

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[Unit]
2+
Description=thinproxy lightweight HTTP/HTTPS proxy
3+
After=network.target
4+
5+
[Service]
6+
Type=simple
7+
ExecStart=/usr/local/bin/thinproxy -f /etc/thinproxy.conf
8+
Restart=on-failure
9+
RestartSec=5
10+
11+
# Security hardening
12+
NoNewPrivileges=yes
13+
ProtectSystem=strict
14+
ProtectHome=yes
15+
PrivateTmp=yes
16+
PrivateDevices=yes
17+
ProtectKernelTunables=yes
18+
ProtectKernelModules=yes
19+
ProtectControlGroups=yes
20+
ReadOnlyPaths=/etc/thinproxy.conf
21+
RestrictNamespaces=yes
22+
RestrictSUIDSGID=yes
23+
MemoryDenyWriteExecute=yes
24+
LockPersonality=yes
25+
26+
[Install]
27+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)