diff options
author | Tiago Natel <t.nateldemoura@f5.com> | 2019-11-26 16:15:23 +0000 |
---|---|---|
committer | Tiago Natel <t.nateldemoura@f5.com> | 2019-11-26 16:15:23 +0000 |
commit | 2f23923e44d4528a547d2a29212ac93c3f0e25de (patch) | |
tree | 5164e0d914be7b2fc4ea676ac6defa6cf90b3b83 /pkg/docker/Dockerfile.tmpl | |
parent | 224787bbaccfc2d065cbc6fb507820fe8d30cf61 (diff) | |
download | unit-2f23923e44d4528a547d2a29212ac93c3f0e25de.tar.gz unit-2f23923e44d4528a547d2a29212ac93c3f0e25de.tar.bz2 |
Changed the group listing to run unprivileged when possible.
Now the nxt_user_groups_get() function uses getgrouplist(3) when available
(except MacOS, see below). For some platforms, getgrouplist() supports
a method of probing how much groups the user has but the behavior is not
consistent. The method used here consists of optimistically trying to get up
to min(256, NGROUPS_MAX) groups; only if ngroups returned exceeds the original
value, we do a second call. This method can block main's process if LDAP/NDIS+
is in use.
MacOS has getgrouplist(3) but it's buggy. It doesn't update ngroups if the
value passed is smaller than the number of groups the user has. Some
projects (like Go stdlib) call getgrouplist() in a loop, increasing ngroups
until it exceeds the number of groups user belongs to or fail when a limit
is reached. For performance reasons, this is to be avoided and MacOS is
handled in the fallback implementation.
The fallback implementation is the old Unit approach. It saves main's
user groups (getgroups(2)) and then calls initgroups(3) to load application's
groups in main, then does a second getgroups(2) to store the gids and restore
main's groups in the end. Because of initgroups(3)' call to setgroups(2),
this method requires root capabilities. In the case of OSX, which has
small NGROUPS_MAX by default (16), it's not possible to restore main's groups
if it's large; if so, this method fallbacks again: user_cred gids aren't
stored, and the worker process calls initgroups() itself and may block for
some time if LDAP/NDIS+ is in use.
Diffstat (limited to 'pkg/docker/Dockerfile.tmpl')
0 files changed, 0 insertions, 0 deletions