我需要unit testing一些bash脚本,我已经在chroot中设置了一个debian挤压。 从命令行我可以使用chroot /目录my-command,或者schroot -d / -u root my-command,但是我需要从由Apache(用户www-data)运行的PHPUnittesting运行这些命令。 随着schroot我有这个错误
E:没有控制terminalE:authentication失败:authentication失败
与sudo chroot我有
sudo:没有tty present,也没有askpass程序
比我更好的主意?
chroot大多数是以root身份运行的。 所以你必须将脚本分成两部分,一部分是unit testing(myapp-unit-test.sh),另一部分是以root身份运行(myapp-unit-test-chroot.sh)。
在/ etc / sudoers中添加:
www-data ALL=(ALL) NOPASSWD:/path/to/myapp-unit-test-chroot.sh
在myapp-unit-test-chroot.sh中执行如下操作:
chroot /new/root sudo -u test-user /path/to/myapp-unit-test.sh
通过这种方式,您将限制以根用户身份运行的部分。