🐛 Fix printf %q empty-var bug; sync Dockerfile; update README 🐛

Three fixes in this commit:
1. printf '%q' empty-variable bug — all 7 init.d service scripts:
printf '%q ' $su_exec/\$args/\$extra_env with an unset/empty variable
calls printf with no vararg, causing bash to format the empty string
as '' (two single-quotes), which gets written into the generated exec
script and makes the container fail to start. Fixed with ${var:+...}
parameter expansion so an empty variable produces an empty string.
2. Dockerfile — sync to template 202605261603 (structural changes:
blank line after $SHELL_OPTS in apk-repos block, un-indented echo ""
in Custom Settings and Custom Applications stubs); preserve all
tor-specific values (IMAGE_NAME, PHP_SERVER, BUILD_DATE, SERVICE_PORT,
EXPOSE_PORTS, PHP_VERSION, IMAGE_REPO, CONTAINER_VERSION, PULL_URL,
PACK_LIST, HOSTNAME, OCI labels).
3. README.md — add the full EXPOSE_PORTS list to the docker run command
and docker-compose ports section (privoxy 8118, SOCKS5 9050, DNS 9053
TCP+UDP, web 9080, bridge range 57000-57007).
- Dockerfile: sync structural template changes; update BUILD_DATE to 202605261603
- README.md: add -p 8118:8118 9050:9050 9053:9053 9053/udp 9080:9080 57000-57007 ports
- rootfs/usr/local/etc/docker/init.d/01-tor-server.sh: fix _q_su/_q_args/_q_extra printf %q guard
- rootfs/usr/local/etc/docker/init.d/02-tor-bridge.sh: fix _q_su/_q_args/_q_extra printf %q guard
- rootfs/usr/local/etc/docker/init.d/03-tor-relay.sh: fix _q_su/_q_args/_q_extra printf %q guard
- rootfs/usr/local/etc/docker/init.d/04-tor-exit.sh: fix _q_su/_q_args/_q_extra printf %q guard
- rootfs/usr/local/etc/docker/init.d/09-unbound.sh: fix _q_su/_q_args/_q_extra printf %q guard
- rootfs/usr/local/etc/docker/init.d/98-privoxy.sh: fix _q_su/_q_args/_q_extra printf %q guard
- rootfs/usr/local/etc/docker/init.d/zz-nginx.sh: fix _q_su/_q_args/_q_extra printf %q guard

Dockerfile
README.md
rootfs/usr/local/etc/docker/init.d/01-tor-server.sh
rootfs/usr/local/etc/docker/init.d/02-tor-bridge.sh
rootfs/usr/local/etc/docker/init.d/03-tor-relay.sh
rootfs/usr/local/etc/docker/init.d/04-tor-exit.sh
rootfs/usr/local/etc/docker/init.d/09-unbound.sh
rootfs/usr/local/etc/docker/init.d/98-privoxy.sh
rootfs/usr/local/etc/docker/init.d/zz-nginx.sh
This commit is contained in:
2026-05-26 18:25:35 -04:00
parent 39519dd564
commit f4df3572d5
9 changed files with 51 additions and 38 deletions
@@ -605,10 +605,10 @@ __run_start_script() {
_q_path=$(printf '%q' "$path")
_q_sysname=$(printf '%q' "$sysname")
_q_svcuser=$(printf '%q' "${SERVICE_USER:-$RUNAS_USER}")
_q_su=$(printf '%q ' $su_exec)
_q_su=${su_exec:+$(printf '%q ' $su_exec)}
_q_cmd=$(printf '%q' "$cmd")
_q_args=$(printf '%q ' $args)
_q_extra=$(printf '%q ' $extra_env)
_q_args=${args:+$(printf '%q ' $args)}
_q_extra=${extra_env:+$(printf '%q ' $extra_env)}
{
printf '#!/usr/bin/env bash\n'
printf "trap 'exitCode=\$?;[ \$exitCode -ne 0 ] && [ -f \"\$SERVICE_PID_FILE\" ] && rm -Rf \"\$SERVICE_PID_FILE\";exit \$exitCode' EXIT\n"
@@ -637,9 +637,9 @@ __run_start_script() {
else
if [ ! -f "$START_SCRIPT" ]; then
local _q_su _q_cmd _q_args
_q_su=$(printf '%q ' $su_exec)
_q_su=${su_exec:+$(printf '%q ' $su_exec)}
_q_cmd=$(printf '%q' "$cmd")
_q_args=$(printf '%q ' $args)
_q_args=${args:+$(printf '%q ' $args)}
{
printf '#!/usr/bin/env bash\n'
printf "trap 'exitCode=\$?;[ \$exitCode -ne 0 ] && [ -f \"\$SERVICE_PID_FILE\" ] && rm -Rf \"\$SERVICE_PID_FILE\";exit \$exitCode' EXIT\n"