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

Subtle bug in os.path.realpath on Cygwin #38825

Closed
edemaine mannequin opened this issue Jul 9, 2003 · 4 comments
Closed

Subtle bug in os.path.realpath on Cygwin #38825

edemaine mannequin opened this issue Jul 9, 2003 · 4 comments
Labels
stdlib Python modules in the Lib dir

Comments

@edemaine
Copy link
Mannequin

edemaine mannequin commented Jul 9, 2003

BPO 768419
Nosy @loewis, @sjoerdmullender

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 2005-03-03.09:52:16.000>
created_at = <Date 2003-07-09.12:38:08.000>
labels = ['invalid', 'library']
title = 'Subtle bug in os.path.realpath on Cygwin'
updated_at = <Date 2005-03-03.09:52:16.000>
user = 'https://bugs.python.org/edemaine'

bugs.python.org fields:

activity = <Date 2005-03-03.09:52:16.000>
actor = 'loewis'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2003-07-09.12:38:08.000>
creator = 'edemaine'
dependencies = []
files = []
hgrepos = []
issue_num = 768419
keywords = []
message_count = 4.0
messages = ['16982', '16983', '16984', '16985']
nosy_count = 4.0
nosy_names = ['loewis', 'sjoerd', 'anadelonbrin', 'edemaine']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue768419'
versions = []

@edemaine
Copy link
Mannequin Author

edemaine mannequin commented Jul 9, 2003

Cygwin allows mounting directories within other mount
points. This can cause os.path.realpath to expand some
symlinks that it shouldn't. For example:

$ cd /
$ mkdir X
$ mkdir X/Y
$ ln -s X Z
$ mount C:/ /Z/Y
$ ls Z/Y
[...contents of C:\...]
$ ls X/Y
[empty directory]

$ python -c "import os; print os.path.realpath('Z/Y')"
/X/Y
[bad because /X/Y is empty yet the original Z/Y has files]

In Cygwin, the correct answer would be either 'C:\\' or
'/cygdrive/c/'.

Conceivably this problem can happen in UNIces other
than Cygwin. It would be rather annoying to fix,
because it would require looking at the mount table.
But I thought I would mention it anyway...

@edemaine edemaine mannequin closed this as completed Jul 9, 2003
@edemaine edemaine mannequin added invalid stdlib Python modules in the Lib dir labels Jul 9, 2003
@edemaine edemaine mannequin closed this as completed Jul 9, 2003
@edemaine edemaine mannequin added invalid stdlib Python modules in the Lib dir labels Jul 9, 2003
@sjoerdmullender
Copy link
Member

Logged In: YES
user_id=43607

I'd think this is rather a Cygwin bug than a Python bug.

Before the mount, /X/Y and /Z/Y refer to the same directory,
and on Unix they have the same device/inode combination.
And that combination is the all-important factor when doing
a mount on that directory.
If you do this on Unix (I used an NFS mount instead of the
mount shown in the report), both /X/Y and /Z/Y contain the
mounted directory.

@anadelonbrin
Copy link
Mannequin

anadelonbrin mannequin commented Jan 30, 2005

Logged In: YES
user_id=552329

I agree with Sjoerd - this is a Cygwin bug, not a Python one.

@loewis
Copy link
Mannequin

loewis mannequin commented Mar 3, 2005

Logged In: YES
user_id=21627

Closing as suggested.

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

No branches or pull requests

1 participant