Skip to content

Commit 4b8d998

Browse files
authored
Fix: setpriv only drop capabilities supported by kernel (#40)
1 parent 2024c39 commit 4b8d998

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

discord/entrypoint.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22

3+
# print kernel/system info
4+
uname -srmo
5+
date
6+
37
if [ -d "default_scripts" ]; then
48
mv default_scripts/* scripts
59
rm -r default_scripts
@@ -21,7 +25,7 @@ $YTDL --version
2125

2226
PID=0
2327

24-
# graceful shutdown
28+
# graceful shutdown on kill
2529
kill_handler() {
2630
echo "Shutting down..."
2731
kill -s SIGINT -$(ps -o pgid= $PID | grep -o '[0-9]*')
@@ -35,7 +39,12 @@ trap 'kill ${!}; kill_handler' SIGTERM # docker stop
3539
trap 'kill ${!}; kill_handler' SIGINT # CTRL + C
3640

3741
if [[ -v UID ]] || [[ -v GID ]]; then
38-
SETPRIV="setpriv --clear-groups --inh-caps=-all"
42+
# WORKAROUND for `setpriv: libcap-ng is too old for "all" caps`, previously "-all" was used here
43+
# create a list to drop all capabilities supported by current kernel
44+
cap_prefix="-cap_"
45+
caps="$cap_prefix$(seq -s ",$cap_prefix" 0 $(cat /proc/sys/kernel/cap_last_cap))"
46+
47+
SETPRIV="setpriv --clear-groups --inh-caps=$caps"
3948

4049
# set user id
4150
if [[ -v UID ]]; then

0 commit comments

Comments
 (0)