[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #25904] NSData writeToFile ignores existing protected file
From: |
Tim Kack |
Subject: |
[bug #25904] NSData writeToFile ignores existing protected file |
Date: |
Tue, 17 Mar 2009 23:24:34 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.7) Gecko/2009030422 Ubuntu/8.10 (intrepid) Firefox/3.0.7 |
URL:
<http://savannah.gnu.org/bugs/?25904>
Summary: NSData writeToFile ignores existing protected file
Project: GNUstep
Submitted by: tkack
Submitted on: Wed 18 Mar 2009 12:24:32 AM CET
Category: Base/Foundation
Severity: 3 - Normal
Item Group: Bug
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
It seems that we are using rename() in NSData.m:1054.
GLibc function rename will first delete the oldfile before renaming the
newfile to the old name.
If a file is readonly, it can still be overwritten by the writeToFile as long
as the containing directory is writable and that the file is owned by the same
owner that executes the tool.
I have attached some simple code to demonstrate this.
Here is the steps:
1. Create a file in /tmp/ called permissionstestFile.txt
2, Add some text in the file
3. chmod 000 /tmp/permissionstestFile.txt
4. Compile testFilePerms tool attached.
5. Run it with './obj/testFilePerms'
6. chmod u+rw /tmp/permissionstestFile.txt
7. cat /tmp/permissionstestFile.txt
Note that this behavior is noted in
http://www.gnu.org/software/libc/manual/html_node/Renaming-Files.html#Renaming-Files
as follows for the rename() function:
"If oldname is not a directory, then any existing file named newname is
removed during the renaming operation. However, if newname is the name of a
directory, rename fails in this case. "
Perhaps there should have a check before renaming if the file is writeable or
not. File attributes are already collected at that point so it shouldn't be
much overhead with the test.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Wed 18 Mar 2009 12:24:32 AM CET Name: GNUmakefile Size: 437B By:
tkack
<http://savannah.gnu.org/bugs/download.php?file_id=17722>
-------------------------------------------------------
Date: Wed 18 Mar 2009 12:24:32 AM CET Name: issue.m Size: 314B By: tkack
<http://savannah.gnu.org/bugs/download.php?file_id=17723>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?25904>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [bug #25904] NSData writeToFile ignores existing protected file,
Tim Kack <=