473,569 Members | 2,626 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("$logPat h/$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 6458
Phil Powell wrote:
[PHP]
print_r(is_file ("$logPath/$logFileName")) ; // RETURNS 1
unlink("$logPat h/$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****@westert erp.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_fil e("$logPath/$logFileName")) ; // RETURNS 1
unlink("$logPa th/$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************ *************@p osting.google.c om>, Phil Powell wrote:
[PHP]
print_r(is_file ("$logPath/$logFileName")) ; // RETURNS 1
unlink("$logPat h/$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
6685
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 in a directory called "files". With an administration form I can read all contents of the data.dat file and select records to delete (one at a...
4
14557
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) in /usr/local/www/vhosts/publicdomainsoftware.org/htdocs/ppUtilityCode/mcAdminImages.php on line 254 I don't get it. If PHP uploads the file,...
1
2792
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 upload on my local machine using simple stuff like: <?php if(file_exists($new_file_name)){
1
1933
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 success..) where can study these php features? cheers.
10
7576
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, which is then processed and the contents are inserted into a new file, created in PHP, onto the server.
6
16756
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
3853
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. The url passes a parameter to the script: e.g. dfile.pl?f=abcde The filename f obviously varies. In the script:
4
1983
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 as user & group apache. I've chowned & chgrouped the file and parent directory (lista). I've chmodded 777 both. I did so from both shell and the...
9
8419
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 <br>$filename <br>Attempting deletion "; if(unlink($destination.$filename)) $exitmsg .= '<br>Success deleting. Please try again '; else
0
7625
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7935
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7992
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6313
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5244
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2128
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 we have to send another system
1
1235
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
969
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.