mirror of
https://github.com/vee1e/mitmproxy.git
synced 2026-09-01 10:18:26 +00:00
Ensure mitmproxy uses /home/mitmproxy/.mitmproxy as the config directory even if the mapped volume is owned by host root, preventing fallback to /root/.mitmproxy and CA file regeneration on redeploy. Add `HOME` env confdir in entrypoint to enforce this behavior. Fixes mitmproxy/mitmproxy#7597
27 lines
668 B
Bash
Executable file
27 lines
668 B
Bash
Executable file
#!/bin/bash
|
|
|
|
set -o errexit
|
|
set -o pipefail
|
|
set -o nounset
|
|
# set -o xtrace
|
|
|
|
MITMPROXY_PATH="/home/mitmproxy/.mitmproxy"
|
|
|
|
if [ -f "$MITMPROXY_PATH/mitmproxy-ca.pem" ]; then
|
|
f="$MITMPROXY_PATH/mitmproxy-ca.pem"
|
|
else
|
|
f="$MITMPROXY_PATH"
|
|
fi
|
|
usermod -o \
|
|
-u $(stat -c "%u" "$f") \
|
|
-g $(stat -c "%g" "$f") \
|
|
mitmproxy \
|
|
>/dev/null # hide "usermod: no changes"
|
|
|
|
if [[ "$1" = "mitmdump" || "$1" = "mitmproxy" || "$1" = "mitmweb" ]]; then
|
|
# Drop privileges if we are starting one of the mitmproxy tools.
|
|
# Set HOME to /home/mitmproxy for config dir fix (mitmproxy/mitmproxy#7597)
|
|
exec env HOME=/home/mitmproxy gosu mitmproxy "$@"
|
|
else
|
|
exec "$@"
|
|
fi
|