fix: drop privileges with a helper of our own, not setpriv
Build docker image and push to registry.bitdeals.org / main-build-job (push) Successful in 1m26s
Build docker image and push to registry.bitdeals.org / main-build-job (push) Successful in 1m26s
Ubuntu 18.04 does not ship setpriv. The program exists in util-linux 2.31, but Debian only began installing it at 2.32, and this image is on bionic because PyBitmessage is Python 2. The build assertion added in the last commit caught it, which is what it is for: `/bin/sh: 1: setpriv: not found`, exit 127, no image pushed. drop_privs.py does the same work with what the image already has. It sets no_new_privs, drops the bounding set with PR_CAPBSET_DROP while CAP_SETPCAP is still held, then optionally becomes the daemon's user. Two shapes, both in run.sh: keep four capabilities and stay root, for the supervisor; keep none and become uid 2000, for the daemon and everything run on its behalf. It is better than setpriv would have been in one respect. The bounding set is walked up to the kernel's own cap_last_cap instead of a list of names, so a capability this image has never heard of goes too -- and the "-all" spelling that bionic's setpriv refuses under a newer kernel is not needed at all. Verified in a user namespace, in the arrangement run.sh uses: the outer drop leaves 00000000000001e0, the inner leaves every capability set at zero with no_new_privs set. The build assertion checks the same two things.
This commit is contained in:
+2
-2
@@ -167,8 +167,8 @@ docker run -d \
|
||||
bounding set из четырёх capability — `SETUID` и `SETGID`, чтобы запускать
|
||||
демона под его собственным пользователем, `KILL` для запасной остановки и
|
||||
`SETPCAP`, чтобы снять остальные, — а каждый запуск демона идёт через
|
||||
`setpriv`: uid 2000, все четыре набора capability пустые, `no_new_privs`
|
||||
включён. Ни на одном файле образа нет бита setuid или setgid, так что
|
||||
`drop_privs.py`: uid 2000, все четыре набора capability пустые,
|
||||
`no_new_privs` включён. Ни на одном файле образа нет бита setuid или setgid, так что
|
||||
захваченному демону не по чему подниматься.
|
||||
|
||||
Три вещи может задать только вызывающая сторона, и все три стоит задать.
|
||||
|
||||
Reference in New Issue
Block a user