1

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?

Cédric Girard
  • 417
  • 2
  • 12
  • 25

1 Answers1

1

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.

Mircea Vutcovici
  • 17,619
  • 4
  • 56
  • 83