[ python-Bugs-768419 ] Subtle bug in os.path.realpath on Cygwin

SourceForge.net noreply at sourceforge.net
Mon Jan 31 00:57:17 CET 2005


Bugs item #768419, was opened at 2003-07-10 00:38
Message generated for change (Comment added) made by anadelonbrin
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=768419&group_id=5470

Category: Python Library
Group: Platform-specific
Status: Open
Resolution: None
Priority: 5
Submitted By: Erik Demaine (edemaine)
Assigned to: Nobody/Anonymous (nobody)
Summary: Subtle bug in os.path.realpath on Cygwin

Initial Comment:
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...

----------------------------------------------------------------------

Comment By: Tony Meyer (anadelonbrin)
Date: 2005-01-31 12:57

Message:
Logged In: YES 
user_id=552329

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

----------------------------------------------------------------------

Comment By: Sjoerd Mullender (sjoerd)
Date: 2003-07-10 01:33

Message:
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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=768419&group_id=5470


More information about the Python-bugs-list mailing list