Skip to content

Instantly share code, notes, and snippets.

@mapk0y
Last active August 29, 2015 14:23
Show Gist options
  • Save mapk0y/1efcd3f98978c6e636b5 to your computer and use it in GitHub Desktop.
Save mapk0y/1efcd3f98978c6e636b5 to your computer and use it in GitHub Desktop.
runc/#28 によって発生している現象

#28

前提

現在、runc コマンドは実行時に chdir(./rootfs) してから exec(argv[0]) している。(古き良き daemon の "/" に移動してからって感じ)

何が起こっているか

以下の様なディレクトリ構成で /opt/sbin がパスに含まれている場合

/
|-opt
  |-sbin
  |  |-runc  <- command
  |-runcdir <- pwd
     |-rootfs

#28 の修正前

  • runc -> OK
  • /opt/sbin/runc -> OK
  • ../sbin/runc -> NG

chdir(/opt/runcdir/rootfs) してから exec(../sbin/runc) しても ../sbin/runc には存在しないので

#28 の修正後

  • runc -> NG
  • /opt/sbin/runc -> OK
  • ../sbin/runc -> OK

単に runc として実行した場合に、filepath.Abs(runc) となって /opt/runcdir/runc になってしまうため

Pull Request #36 の動作確認

jessie:~# tree -L 2 -I 'local|VBox*' /opt
/opt
├── runcdir
│   ├── container.json
│   └── rootfs
└── sbin
    └── runc

jessie:~# cd /opt/runcdir/

# ${PATH}
jessie:/opt/runcdir# PATH=/opt/sbin:${PATH} runc                                                                                                                                                                                             
daemon@shell:/$ exit

# absolute path
jessie:/opt/runcdir# /opt/sbin/runc 
daemon@shell:/$ exit

# relative path
jessie:/opt/runcdir# ../sbin/runc 
daemon@shell:/$ exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment