Linux sandboxing

問題:

  1. hako 的功能為何?
  2. hako 如何運用在本專案?
  3. 如何改進 hako ?

可以從官網中看到有關 hako 功能的描述:

  • chroot + Linux namespace
  • run on a read-only filesystem
  • privilege dropping (早期階段)
  • Networking-> 沙盒可以使用 host 端或是其他沙盒的網路

解析程式碼:

0. creating

建立 sandbox 並對其配置

$ mkdir sandbox
$ mkdir sandbox/.hako
$ touch sandbox/.hako/init
$ chmod +x sandbox/.hako/init
$ mkdir sandbox/bin
$ touch sandbox/bin/busybox
$ ln -s busybox sandbox/bin/sh

之後要加入整個 debian 檔案系統

1. hako-enter.c

2. hako-run.c

照著 README 的指示輸入 hako-run sandbox /bin/sh 命令時會遇到 hako-run: command not found ,要輸入 sudo ./hako-run sandbox 才能進入 sandbox

使用上的差異:
hako-run --pid-file sandbox.pid sandboxhako-enter --fork $(cat sandbox.pid) /bin/sh
??

加入 debian 檔案系統

建立 Debian root file system 有提到如何建立 debian 檔案系統以及如何驗證,因此在此處聚焦在如何用