![]() |
| | #1 |
| Registered User Join Date: Nov 2007
Posts: 2
| Deletion of open named pipes Please note that the named pipe was created with permissions 0400. This means only the owner would have the right to modify/delete it, right? The process that deleted it had a different UID and GID. So its not making sense to me how a "rogue" process can just come and delete a file being used by someone else without even having modify permissions on it. The only thing I can think of is that the directory permissions are 0777 and that is why he can delete it. Still, the behaviour sounds a little wierd that a busy system file is not locked against deletion. |
| sparkymat is offline | |
| | #2 | ||
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,768
| Quote:
One of the basic ideas in UNIX is that an open file can be moved or deleted at will. The file/device/FIFO itself will continue to exist, without a name, until it is closed by the last process which has a descriptor on it. Coming from a Windows background people are used to thinking that a file which is "in use" is somehow protected from certain kinds of operations. Not true on UNIX. Quote:
So, to prevent deletion of the FIFO, make a directory, put the FIFO in this directory, then remove write permissions on the directory. | ||
| brewbuck is offline | |
| | #3 |
| Registered User Join Date: Nov 2007
Posts: 2
| So even if the 2nd process deletes the FIFO file, the opening process can continue using it as long as it has the descriptor? |
| sparkymat is offline | |
| | #4 | |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Quote:
-- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. | |
| matsp is offline | |
| | #5 |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,768
| Sure -- but in this case, it means your process will hang forever. The call to open() is blocking, waiting for someone to open the write end of the pipe. But because the directory entry has been removed, it is impossible for anybody to open the pipe, because it has no name. The FIFO is still there, but it has become useless because nobody can refer to it. Once you kill the hung process, the last descriptor closes and the FIFO object goes away. |
| brewbuck is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Open Source and Security | DavidP | General Discussions | 17 | 06-17-2008 01:23 AM |
| Open Software License 3.0 Explained | laserlight | General Discussions | 8 | 01-08-2008 08:10 PM |
| open empty file | mystic-d | C Programming | 2 | 11-16-2007 10:27 AM |
| To open or not to open ? | darfader | C Programming | 7 | 09-24-2003 08:14 AM |
| Ghost in the CD Drive | Natase | A Brief History of Cprogramming.com | 17 | 10-12-2001 05:38 PM |