469,275 Members | 1,450 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

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 6136
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Eric | last post: by
1 post views Thread by Chamomile | last post: by
1 post views Thread by David | last post: by
10 posts views Thread by lorenzogordon | last post: by
6 posts views Thread by Benjamin | last post: by
7 posts views Thread by daithimcc | last post: by
4 posts views Thread by lukaszmn | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.