classification
Title: os.remove can be used to remove directories on SunOS
Type: Stage:
Components: Versions: 3rd party
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: giampaolo.rodola, loewis
Priority: normal Keywords:

Created on 2008-10-26 17:48 by giampaolo.rodola, last changed 2008-10-26 19:12 by giampaolo.rodola. This issue is now closed.

Messages (3)
msg75238 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2008-10-26 17:48
Done against a SunOS 5.10 equipped with Python 2.4.4.

>>> import os
>>> os.mkdir('foo')
>>> os.remove('foo')
>>>
msg75240 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-10-26 18:49
I cannot reproduce the behavior that your trace suggests; instead, I get

>>> os.remove("foo")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OSError: [Errno 1] Not owner: 'foo'

Perhaps you were trying to do this as root?

This is a known issue with Solaris: it allows to call unlink(2) for
directories. This is documented in unlink(2) as

     If the path argument is a directory and the filesystem  sup-
     ports  unlink() and unlinkat() on directories, the directory
     is unlinked from its parent with no cleanup being performed.
     In  UFS,  the  disconnected directory will be found the next
     time the filesystem is checked with fsck(1M).  The  unlink()
     and  unlinkat()  functions  will  not  fail simply because a
     directory is not empty. The user with appropriate privileges
     can orphan a non-empty directory without generating an error
     message.

     If the path argument is a directory and the filesystem  does
     not  support unlink() and unlink() on directories (for exam-
     ple, ZFS), the call will fail with errno set to EPERM.

As os.remove is the same as unlink, and as os.unlink deliberately calls
the system call, this is not a bug in Python.

Closing it as "won't fix, 3rd party".
msg75242 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2008-10-26 19:12
I didn't know about such unlink behavior and yes, I was root.
Thanks for the precious infos.
History
Date User Action Args
2008-10-26 19:12:19giampaolo.rodolasetmessages: + msg75242
2008-10-26 18:49:58loewissetstatus: open -> closed
resolution: wont fix
messages: + msg75240
nosy: + loewis
versions: + 3rd party
2008-10-26 17:48:49giampaolo.rodolacreate