feat: impersonator middleware feature/usability improvements #353
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
this patch tackles 3 major issues of the current implementation of impersonator:
1. handling additional groups
unix users could retrieve groups they belongs with
idcommand, it is common that a user belongs to multiple additional groups than the one which named identical to him/herself. here below is an example retrieving my groups on my linux workstation:the current implementation, wsgidav only call
os.setegid(1000)when impersonating asleoon this machine, while other groups, incl.wireshark,docker, etc, should also be added.this patch handles such cases with
os.initgroups()to properly add additional groups accordingly (to/etc/group) when impersonating.2. rejecting system users
uids <= 999 on unix systems are generally preserved for system daemon uses, a sysadmin may not want someone being capable to impersonate as such users. (probably due to misconfiguration of domain controller, etc)
this patch adds an option to reject impersonating-as-system-users attemps:
3. docker capability issues
docker's
--cap-add(orcap_add:in docker-compose.yml) does not add the capabilities to the ambient set, therefore the capability is dropped uponfork()/execve(), (which is behind gunicorn's worker spawning) rendering the approach described in #343 (comment) not feasible.this patch included a statically-linked helper program in C to achieve this in containers.