Page 1 of 1

Permission denied in Unknown on line 0

Posted: Sun Jun 18, 2006 11:53 am
by fopetesl
I have switched my OS from Mandrake 10.0CE to Ubuntu 5.10 (Breezy) and now cannot get even a simple php script to run even with exec()..

Code: Select all

<?php
`sudo /sbin/halt`;
?>
Trying to execute the script from Opera,(I need for kiosk), I get the following:

Code: Select all

Warning: Unknown(/var/www/html/testshutdown.php): failed to open stream: Permission denied in Unknown on line 0

Warning: (null)() [function.include]: Failed opening '/var/www/html/testshutdown.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
I have checked permissions in /etc/sudoers so doesn't seem to be a permission problem.
Also file permission is the same as:

Code: Select all

<?php
phpinfo();
?>
which does work.

There are no errors reported by apache.

Using exec() to run the same command gives me the same error.

I do not have either /usr/share/php -or- /usur/share/pear. Should I have?

Posted: Sun Jun 18, 2006 12:25 pm
by tecktalkcm0391
Did you reinstall PHP? That might help.

Posted: Sun Jun 18, 2006 5:10 pm
by shiznatix
your permissions are probably wrong. you have to make sure that your script is executable by your web server. make sure of that.

PHP4: Over ride sudo password [SOLVED]

Posted: Mon Jun 19, 2006 5:57 am
by fopetesl
It seems that the order in which sudo authentications are placed into the sudoers file is significant.
Note my first attempt failed but this one succeeds:

Code: Select all

# User privilege specification 
root ALL=(ALL) ALL 
user_me ALL=(ALL) NOPASSWD:ALL 
apache2 ALL=(ALL) NOPASSWD:ALL # seems not to be significant?
php4 ALL=(ALL) NOPASSWD:ALL    # -------- " --------------- 

# Members of the admin group may gain root privileges 
%admin ALL=(ALL) NOPASSWD:ALL 
%www-data ALL=(ALL) NOPASSWD:ALL # !! IS significant !!
which is not particularly secure so I need to tidy that up.