Permission denied in Unknown on line 0

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fopetesl
Forum Newbie
Posts: 7
Joined: Mon Oct 11, 2004 1:45 pm
Location: Yorkshire Dales UK

Permission denied in Unknown on line 0

Post 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?
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

Did you reinstall PHP? That might help.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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.
fopetesl
Forum Newbie
Posts: 7
Joined: Mon Oct 11, 2004 1:45 pm
Location: Yorkshire Dales UK

PHP4: Over ride sudo password [SOLVED]

Post 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.
Post Reply