Browse Source

checking for access to pid ns

Grega Bremec 2 years ago
parent
commit
c3e3b140cb
1 changed files with 6 additions and 0 deletions
  1. 6 0
      images/entrypoint-psacct.sh

+ 6 - 0
images/entrypoint-psacct.sh

@@ -12,6 +12,12 @@ if [ -z "$(capsh --decode=$(cat /proc/self/status | grep ^CapEff | cut -f2) | gr
     exit 1
 fi
 
+# Die if running as PID 1 (no access to host PID namespace)
+if [ $$ -eq 1 ]; then
+    echo "FATAL: Need access to host PID namespace, can't seriously be PID 1."
+    exit 1
+fi
+
 # Shutdown handler.
 trap_shutdown() {
     echo "Shutting down..."