473,513 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cannot unlink file that Apache and I have permissions to delete

[PHP]
print_r(is_file("$logPath/$logFileName")); // RETURNS 1
unlink("$logPath/$logFileName"); // RETURNS WARNING: PERMISSION DENIED
[/PHP]

This code should tell me that the file located at
$logPath/$logFileName should delete the log file, however, it never
deletes it due to permissions error.

However, upon checking the file properties I find this:
  • I am a member of the group with full permissions to edit/write/delete
    the file
    Apache is a member of the same group with full permissions to
    edit/write/delete the file
    Apache and I are in the group that has full permissions to
    edit/write/delete all other files in the exact same folder and those
    can ALL be edited, written or deleted

This file was created and transferred the same way as all others, is a
text file and contains only text, no binary characters of any kind.
However, it can never be deleted even though I have permissions to do
so as does Apache.

What could I be doing wrong?

Thanx
Phil
Jul 17 '05 #1
5 6451
Phil Powell wrote:
[PHP]
print_r(is_file("$logPath/$logFileName")); // RETURNS 1
unlink("$logPath/$logFileName"); // RETURNS WARNING: PERMISSION DENIED
[/PHP]

This code should tell me that the file located at
$logPath/$logFileName should delete the log file, however, it never
deletes it due to permissions error.

However, upon checking the file properties I find this:

  • > I am a member of the group with full permissions to edit/write/delete
    the file
    Apache is a member of the same group with full permissions to
    edit/write/delete the file
    Apache and I are in the group that has full permissions to
    edit/write/delete all other files in the exact same folder and those
    can ALL be edited, written or deleted
>
This file was created and transferred the same way as all others, is a
text file and contains only text, no binary characters of any kind.
However, it can never be deleted even though I have permissions to do
so as does Apache.

What could I be doing wrong?

Thanx
Phil


I don't know all that much about (linux?) file permissions, but my first
thought was: is the file perhaps locked by another process/owner at the time
of attempted deletion ?

HTH
Pjotr
Jul 17 '05 #2
On Wed, 28 Jul 2004 19:43:43 +0200, "Pjotr Wedersteers" <x3****@westerterp.com>
wrote:
I don't know all that much about (linux?) file permissions, but my first
thought was: is the file perhaps locked by another process/owner at the time
of attempted deletion ?


Typically this just results in the file disappearing from the visible
filesystem, but the file still staying allocated and accessible by the
process(es) that have it open until they all release the file, at which point
the inode gets cleared up and the space released.

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #3
>
  • I am a member of the group with full permissions to edit/write/delete
    the file
    Apache is a member of the same group with full permissions to
    edit/write/delete the file
    Apache and I are in the group that has full permissions to
    edit/write/delete all other files in the exact same folder and those
    can ALL be edited, written or deleted


it is not important your permissions or your gruop.
only apache is important.

have you checked if the file is writable by the group ?
if the file is yours of your gruop but only you can write it apache can
do nothing.
Jul 17 '05 #4
>[PHP]
print_r(is_file("$logPath/$logFileName")); // RETURNS 1
unlink("$logPath/$logFileName"); // RETURNS WARNING: PERMISSION DENIED
[/PHP]

This code should tell me that the file located at
$logPath/$logFileName should delete the log file, however, it never
deletes it due to permissions error.

However, upon checking the file properties I find this:

  • >I am a member of the group with full permissions to edit/write/delete
    the file
    Apache is a member of the same group with full permissions to
    edit/write/delete the file
    Apache and I are in the group that has full permissions to
    edit/write/delete all other files in the exact same folder and those
    can ALL be edited, written or deleted

Show me the permissions and ownerships, on both the file and the
directory it's in. Also, what user/group does Apache run as?

What OS has an "edit" permission on files? If this is a UNIX-like
OS, is it on a read-only filesystem? Does it have the immutable
bit set? Does it have the system or user-level undeletable bit
set? What type of object is it? (You can't unlink() a directory).

Is it possible that this is a *PHP* "permission denied", not an *OS*
"permission denied"? Is safe mode on?

This file was created and transferred the same way as all others, is a
text file and contains only text, no binary characters of any kind.
However, it can never be deleted even though I have permissions to do
so as does Apache.


Gordon L. Burditt
Jul 17 '05 #5
In article <1c*************************@posting.google.com> , Phil Powell wrote:
[PHP]
print_r(is_file("$logPath/$logFileName")); // RETURNS 1
unlink("$logPath/$logFileName"); // RETURNS WARNING: PERMISSION DENIED
[/PHP]

This code should tell me that the file located at
$logPath/$logFileName should delete the log file, however, it never
deletes it due to permissions error.

However, upon checking the file properties I find this:

This file was created and transferred the same way as all others, is a
text file and contains only text, no binary characters of any kind.
However, it can never be deleted even though I have permissions to do
so as does Apache.

What could I be doing wrong?


Are you able to delete it using the shell and/or FTP?

I'm assuming UNIX. (Because I can't help much with windows..)

My first guess is that Apache is "running as" another user. Assuming
you've already tried it..

Is it possible the directory was chmod'd?

Is Apache serving content from a directory mounted via NFS? (If so,
could the filesystem have been mounted read only?)

One thing to check is if Apache is able to create files in the same
directory. If so, then you can be reasonably sure the problem is with
the file itself.

If Apache can create files in the same directory, do a compare on file
ownerships.

Another thing to check, if you've got shell access are any extended
attributes. lsattr might do the trick if it's an ext* file system. I've
spent a few hours puzzling over that one before. :-) chattr is a handy
way to keep your "kid sister" or root from accidently zapping critical
files. Sometimes log files are set with an "append only" attribute.

Jamie
--
http://www.geniegate.com Custom web programming
User Management Solutions Perl / PHP / Java / UNIX

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6678
by: Eric | last post by:
Hello, I created a form to upload files. The formfield contents are stored as records in an Ascii file "data.dat"; for reasons I am not using a MySql database. The upoaded file itself is stored...
4
14550
by: lawrence | last post by:
I wrote some code that let me upload a file to my server. Then I wrote some code to let me delete the file. But when I try to delete, I get this error: Warning: Unlink failed (Permission denied)...
1
2782
by: Chamomile | last post by:
I am having trouble getting unlink() to work on my local machine (win 2000, Apache, php 4.2.2) when I invoke unlink() in order to change a file name during a 'picture edit' change from a form...
1
1927
by: David | last post by:
Hi all.. I need a web page who can delete some files into a web server directory with a form and checkbox.. can somebody forward me in a right web page ( I look into php.net without...
10
7559
by: lorenzogordon | last post by:
Hi there, I'd greatly appreciate any insights into the following problem: I've got PHP running fine on IIS (OS: Server 2003, SP1; IIS: 6.0; PHP: 4.3.11). In PHP, the user uploads a file,...
6
16752
by: Benjamin | last post by:
Hello, I'm running PHP 5.2.0 as a Apache 2.2 server module. When, I try to unlink I get this: "Warning: unlink(file.txt) : Permission denied..." What and how do I change this so it works? Thanks
7
3845
by: daithimcc | last post by:
I have been trying to delete a file using a script and it is refusing to go. (I have very little experience of Perl). One script creates the temporary file (empty) and later another is to delete it....
4
1981
by: lukaszmn | last post by:
Hey I've been searching the internet and manuals for help for hours and I'm still clueless. I wanted to delete a file in /var/www/html/ lista from a script /var/www/html/lista-drop.php. Apache runs...
9
8408
code green
by: code green | last post by:
I have this piece of code to tidy up after a function that calls move_uploaded_file() if(file_exists($destination.$filename)) { $exitmsg .= "<br>File still in temporary location...
0
7265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7171
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7111
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7539
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5692
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3240
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
461
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.