Skip to content

Commit 447db8b

Browse files
authored
Use CAP_NET_BIND_SERVICE (#281)
1 parent b363d97 commit 447db8b

9 files changed

Lines changed: 10 additions & 33 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,7 @@ jobs:
215215
--version ${{ env.VERSION }}
216216
--package defguard-proxy-${{ env.VERSION }}_x86_64-unknown-freebsd.pkg
217217
--freebsd-osversion '*'
218-
--depends openssl
219-
--before-install freebsd/preinst
220-
--after-remove freebsd/postrm"
218+
--depends openssl"
221219

222220
- name: Upload Linux x86_64 archive
223221
uses: shogo82148/actions-upload-release-asset@v1

docs/header.png

-496 Bytes
Loading

freebsd/postrm

Lines changed: 0 additions & 9 deletions
This file was deleted.

freebsd/preinst

Lines changed: 0 additions & 13 deletions
This file was deleted.

linux/defguard-proxy.service

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ After=network-online.target
77
[Service]
88
User=defguard
99
Group=defguard
10+
AmbientCapabilities=CAP_NET_BIND_SERVICE
11+
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
1012
ExecReload=/bin/kill -HUP $MAINPID
1113
ExecStart=/usr/bin/defguard-proxy --config /etc/defguard/proxy.toml
1214
KillMode=process

linux/postinst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ case "${1}" in
1414
abort-upgrade | abort-remove | abort-deconfigure)
1515
if [ -x /usr/bin/systemctl ]; then
1616
/usr/bin/systemctl daemon-reload
17-
if /usr/bin/systemctl is-enabled ${SERVICE_NAME} >/dev/null 2>&1; then
18-
/usr/bin/systemctl start ${SERVICE_NAME} || true
17+
if /usr/bin/systemctl is-enabled --quiet ${SERVICE_NAME}; then
18+
/usr/bin/systemctl --no-block restart ${SERVICE_NAME}
1919
fi
2020
fi
2121
;;

linux/postrm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ set -e
44
USERNAME=defguard
55

66
if [ -x /usr/bin/systemctl ]; then
7-
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 || true
7+
/usr/bin/systemctl --quiet daemon-reload || true
88
fi
99

10-
if id -u ${USERNAME} >/dev/null 2>&1
11-
then
12-
echo "If no longer needed, remove ${USERNAME} manually: userdel ${USERNAME}"
10+
if id -u ${USERNAME} >/dev/null 2>&1; then
11+
echo "If no longer needed, remove ${USERNAME} manually: userdel ${USERNAME}"
1312
fi

linux/preinst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ if ! id -u ${USERNAME} >/dev/null 2>&1; then
88
fi
99

1010
mkdir -p /etc/defguard
11-
chown ${USERNAME}:${USERNAME} /etc/defguard
11+
chown -R ${USERNAME}:${USERNAME} /etc/defguard
1212
chmod 750 /etc/defguard

linux/prerm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ set -e
44
SERVICE_NAME='defguard-proxy'
55

66
if [ -x /usr/bin/systemctl ]; then
7-
/usr/bin/systemctl --no-block stop ${SERVICE_NAME} >/dev/null 2>&1 || true
7+
/usr/bin/systemctl --no-block --quiet stop ${SERVICE_NAME} || true
88
fi

0 commit comments

Comments
 (0)