1

I want to run an sh script from php. For this, i need to open visudo file:

sudo visudo

With this:

www-data ALL=(ALL) NOPASSWD: ALL

It works!

But I dont want to enable all command, just a specific sh script. So i changed it to:

www-data ALL=(ALL) NOPASSWD: /www/......./truncatefiles.sh

The path is correct, but shell_exec (from php) returns: sudo: no tty present and no askpass program specified And the command wont run. If the visudo line is same as my first example.

What can be the problem?

bbenhu
  • 23
  • 4

1 Answers1

0

I think this is a bad idea cause it can create a potential security issue.

But if you still want to do so, you can keep www-data ALL=(ALL) NOPASSWD: /www/......./truncatefiles.sh and at the same time comment out the line that contain Defaults requiretty in /etc/sudoers (always with visudo to avoid errors).

funilrys
  • 787
  • 9
  • 20