Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os.remove can be used to remove directories on SunOS #48460

Closed
giampaolo opened this issue Oct 26, 2008 · 3 comments
Closed

os.remove can be used to remove directories on SunOS #48460

giampaolo opened this issue Oct 26, 2008 · 3 comments

Comments

@giampaolo
Copy link
Contributor

BPO 4210
Nosy @loewis, @giampaolo

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2008-10-26.18:49:58.456>
created_at = <Date 2008-10-26.17:48:49.054>
labels = []
title = 'os.remove can be used to remove directories on SunOS'
updated_at = <Date 2008-10-26.19:12:19.006>
user = 'https://github.com/giampaolo'

bugs.python.org fields:

activity = <Date 2008-10-26.19:12:19.006>
actor = 'giampaolo.rodola'
assignee = 'none'
closed = True
closed_date = <Date 2008-10-26.18:49:58.456>
closer = 'loewis'
components = []
creation = <Date 2008-10-26.17:48:49.054>
creator = 'giampaolo.rodola'
dependencies = []
files = []
hgrepos = []
issue_num = 4210
keywords = []
message_count = 3.0
messages = ['75238', '75240', '75242']
nosy_count = 2.0
nosy_names = ['loewis', 'giampaolo.rodola']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue4210'
versions = ['3rd party']

@giampaolo
Copy link
Contributor Author

Done against a SunOS 5.10 equipped with Python 2.4.4.

>> import os
>> os.mkdir('foo')
>> os.remove('foo')
>>

@loewis
Copy link
Mannequin

loewis mannequin commented Oct 26, 2008

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".

@loewis loewis mannequin closed this as completed Oct 26, 2008
@giampaolo
Copy link
Contributor Author

I didn't know about such unlink behavior and yes, I was root.
Thanks for the precious infos.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant