Don't ask me why, but I have to find a way to allow the Apache user
www-data to mount and unmount devices at run-time on the host system. Such devices are, for example, external USB drives on
/dev/sdaXY formatted with NTFS filesystem.
I'm running the web service on a Debian machine using Apache 2.2 and PHP 5.3. When I try to run the
mount command via PHP's
exec() I obviously have these error message:
exec('mount /dev/sda1 /media/usb_flash'); // -> mount: only root can do that exec('sudo mount /dev/sda1 /media/usb_flash'); // -> sudo: no tty present and no askpass program specified exec('sudo -n mount /dev/sda1 /media/usb_flash'); // -> sudo: sorry, a password is required to run sudo
I'm aware only root can do that (in fact, from SSH, I always need
sudo when mounting) and that
www-data cannot be a sudoer. But I'm sure there's a way, a workaround, to make my task possible. I don't know where to start looking at: Googling my question is useless, I bet this is not a common scenario.