I need to unit test some bash scripts, I have setup a debian squeeze in a chroot. From command line I can use chroot /directory my-command, ou schroot -d / -u root my-command, but I need to run theses commands from a PHPUnit test, runned by Apache (user www-data). With schroot I have this error
E: No controlling terminal E: Authentication failed: Authentication failure
with sudo chroot I have
sudo: no tty present and no askpass program specified
Better idea than me?
chroot
most be run as root. So you have to split your script in two, one that is doing the unit test (myapp-unit-test.sh) and one that will be run as root (myapp-unit-test-chroot.sh).In /etc/sudoers add:
In myapp-unit-test-chroot.sh do something like:
In this way you will limit the part that is running as root.