Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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/PHPUnit-script.sh –  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

1 Answer 1

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 (myapp-unit-test.sh) and one that will be run as root (myapp-unit-test-chroot.sh).

In /etc/sudoers add:

www-data ALL=(ALL) NOPASSWD:/path/to/myapp-unit-test-chroot.sh

In myapp-unit-test-chroot.sh do something like:

chroot /new/root sudo -u test-user /path/to/myapp-unit-test.sh

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

share|improve this answer

Your Answer

 
discard

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.