clarkk
clarkk

Reputation: 27669

sudo doesnt have access even though it is added with sudo visudo

I get this error when running a program from www-data.

Error

sudo: no tty present and no askpass program specified

But I have added the following to sudo visudo

www-data ALL = NOPASSWD: /var/bin/poppler-0.65.0/build/utils/pdfimages

The path /var/bin/poppler-0.65.0/build/utils/pdfimages is correct.. I have tested it from a terminal.

Command

sudo /var/bin/poppler-0.65.0/build/utils/pdfimages -list data/scan_voucher/17.pdf

Upvotes: 2

Views: 296

Answers (1)

JP. Aulet
JP. Aulet

Reputation: 4398

As you said that already setting up sudo visudo correctly, I will first take a look at Tarun Lalwani links, specially the part about disable requiring tty in your sudoers :

Defaults    !requiretty

Try to do the same command but with flag -S actived (sudo -S yourcommand)

The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device.

If it doesn't work for you, you can try a trick that seems to work like this one (from here):

echo '' | sudo -S your_command

That will send an empty password to first prompt to enter password.

How are you executing this from PHP? Try with:

@exec("sudo /var/bin/poppler-0.65.0/build/utils/pdfimages -list data/scan_voucher/17.pdf");

Hope that it helps!

Upvotes: 1

Related Questions