forked from DL-Mirrors/termux-docker
docker: update entrypoint script
* Split conditional for non-root check. * Force-drop privileges to user "system".
This commit is contained in:
@@ -1,21 +1,24 @@
|
|||||||
#!/system/bin/sh
|
#!/system/bin/sh
|
||||||
|
|
||||||
if [ "$(id -u)" = "0" ] && [ -z "$(/system/bin/busybox pidof dnsmasq)" ]; then
|
if [ "$(id -u)" = "0" ]; then
|
||||||
|
if [ -z "$(/system/bin/busybox pidof dnsmasq)" ]; then
|
||||||
/system/bin/mksh -T /dev/ptmx -c "/system/bin/dnsmasq -u root -g root --pid-file /dnsmasq.pid" >/dev/null 2>&1
|
/system/bin/mksh -T /dev/ptmx -c "/system/bin/dnsmasq -u root -g root --pid-file /dnsmasq.pid" >/dev/null 2>&1
|
||||||
sleep 1
|
sleep 1
|
||||||
if [ -z "$(/system/bin/busybox pidof dnsmasq)" ]; then
|
if [ -z "$(/system/bin/busybox pidof dnsmasq)" ]; then
|
||||||
echo "[!] Failed to start dnsmasq, host name resolution may fail." >&2
|
echo "[!] Failed to start dnsmasq, host name resolution may fail." >&2
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "[!] Container is running as non-root, unable to start dnsmasq. DNS will be unavailable." >&2
|
echo "[!] Container is running as non-root, unable to start dnsmasq. DNS will be unavailable." >&2
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $# -ge 1 ]; then
|
if [ $# -ge 1 ]; then
|
||||||
exec "$@"
|
exec /data/data/com.termux/files/usr/bin/bash -c "$@"
|
||||||
else
|
|
||||||
if [ "$(id -u)" = "0" ]; then
|
|
||||||
exec /system/bin/su - system -c "/data/data/com.termux/files/usr/bin/login"
|
|
||||||
else
|
else
|
||||||
exec /data/data/com.termux/files/usr/bin/login
|
exec /data/data/com.termux/files/usr/bin/login
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ $# -ge 1 ]; then
|
||||||
|
exec /system/bin/su - system -c "/data/data/com.termux/files/usr/bin/bash -c \"$@\""
|
||||||
|
else
|
||||||
|
exec /data/data/com.termux/files/usr/bin/login
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user