Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Solution high security inside : www-data ALL=(ALL:ALL) NOPASSWD: ALL in /etc/sudoers, and it run... I am not happy! ;-) – Cédric Girard Dec 7 '11 at 14:38
Try to use www-data ALL=(ALL) NOPASSWD: /path/to/your/ – Mircea Vutcovici Dec 7 '11 at 14:40
Right, your is better (smaller security hole) than mine :-D – Cédric Girard Dec 7 '11 at 14:47
up vote 1 down vote accepted

chroot most be run as root. So you have to split your script in two, one that is doing the unit test ( and one that will be run as root (

In /etc/sudoers add:

www-data ALL=(ALL) NOPASSWD:/path/to/

In do something like:

chroot /new/root sudo -u test-user /path/to/

In this way you will limit the part that is running as root.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.