Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have 2 folders:

drwsrwsr-x 25 ftpuser www-data 4096 Jun  7 13:45 demo
drwsrwsr-x 28 ftpuser www-data 4096 Jun  7 12:43 dev

and a script to create a folder within these.

When I run the script like this

php exec("sudo bash doit.sh $path") 

setting $path to

/var/www/dev/newfolder/ 

and when the script executes the command:

mkdir $1

it gives me the sudo no password error:

"sudo: no tty present and no askpass program specified"

the thing is, when i switch the path back to

/var/www/demo/newfolder/

it works!!!

an ideas?

share|improve this question
2  
What do you have in your sudoers file? –  Zoredache Jun 7 '12 at 18:20
    
Are you sure it's not just a case of a cached sudo password for your user in the demo case? Run sudo -K before each script execution to be sure. –  Daniel Beck Jun 7 '12 at 18:23
    
Add an answer to your question then, about how you changed your sudoers file. –  Zoredache Jun 7 '12 at 18:34
    
php exec("sudo bash doit.sh $path") Everytime I think I've seen enough PHP abominations, something new comes up...If $path is passed in from a web-application or some outside source, you'd better do a ton of verifications on that. –  Bobby Jun 7 '12 at 19:00
    
actually the error prevails despite having added the folder to the NOPASSWD exceptions in the sudoers file (of which demo is an entry) when i ran sudo -K i got username|#uid] file ... –  drunken master Jun 7 '12 at 19:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.