比如 test01 执行个轮子后,进入了一个隔离的 chroot 类似。
主要是 web 上点击提供一个 web shell 类似,里面的 rootfs 带了 kubectl ,目前同事用 webkubectl 项目使用,但是前不久客户让改为非 root 启动。大致看了下它的实现
- 特权容器内 root 用户执行 gotty 启动 start-session.sh 作为 pid 为 1 的角色
-
每次访问 web 就是执行 start-session.sh 的内容
- unshare --fork --pid --mount-proc --mount xxx.sh 启动隔离空间
- mkdir -p /nonexistent ,mount -t tmpfs -o size=${SESSION_STORAGE_SIZE} tmpfs /nonexistent 和一系列处理文件
- exec su nobody bash
然后改为非 root 启动 gotty 后,没有执行 unshare 和 mount 权限,所以来问下有没有什么轮子,非 root 用户执行,能 chroot 到一个小巧的 rootfs 内的 shell 交互(该 shell 内什么用户都行,对 chroot 之前的无影响)。目前试过 proot ,容器内 root 都无法启动