Bläddra i källkod

dockerd-rootless.sh: prohibit running as root

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit 9351e196587b73baecfe187b4bc4c3694da608fb)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Akihiro Suda 4 år sedan
förälder
incheckning
1015b5b438
1 ändrade filer med 4 tillägg och 0 borttagningar
  1. 4 0
      contrib/dockerd-rootless.sh

+ 4 - 0
contrib/dockerd-rootless.sh

@@ -80,6 +80,10 @@ fi
 if [ -z $_DOCKERD_ROOTLESS_CHILD ]; then
 	_DOCKERD_ROOTLESS_CHILD=1
 	export _DOCKERD_ROOTLESS_CHILD
+	if [ "$(id -u)" = "0" ]; then
+		echo "This script must be executed as a non-privileged user"
+		exit 1
+	fi
 	# Re-exec the script via RootlessKit, so as to create unprivileged {user,mount,network} namespaces.
 	#
 	# --copy-up allows removing/creating files in the directories by creating tmpfs and symlinks