Docker: assume uid of who holds permissions (#5550)

* Docker: assume uid of who holds permissions

* add docs
This commit is contained in:
Maximilian Hils 2022-09-08 19:42:09 +02:00 committed by GitHub
parent 891dae031c
commit 8023b22498
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -45,6 +45,7 @@ Proxy server listening at http://*:8080
[...]
```
If `~/.mitmproxy/mitmproxy-ca.pem` is present in the container, mitmproxy will assume uid and gid from the file owner.
For further details, please consult the mitmproxy [documentation](http://docs.mitmproxy.org/en/stable/).
## Tags

View File

@ -9,7 +9,12 @@ MITMPROXY_PATH="/home/mitmproxy/.mitmproxy"
if [[ "$1" = "mitmdump" || "$1" = "mitmproxy" || "$1" = "mitmweb" ]]; then
mkdir -p "$MITMPROXY_PATH"
chown -R mitmproxy:mitmproxy "$MITMPROXY_PATH"
if [ -f "$MITMPROXY_PATH/mitmproxy-ca.pem" ]; then
usermod -o \
-u $(stat -c "%u" "$MITMPROXY_PATH/mitmproxy-ca.pem") \
-g $(stat -c "%g" "$MITMPROXY_PATH/mitmproxy-ca.pem") \
mitmproxy
fi
gosu mitmproxy "$@"
else
exec "$@"