[ python-Bugs-990669 ] os.path.realpath() does not handle symlinks
correctly
SourceForge.net
noreply at sourceforge.net
Wed Jul 14 06:58:40 CEST 2004
Bugs item #990669, was opened at 2004-07-14 00:58
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=990669&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Anton Koinov (dave0000)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.path.realpath() does not handle symlinks correctly
Initial Comment:
os.path.realpath() does not handle symlinks properly on
Linux (at least, does not do it the same way as the
Linux file functions do).
To reproduce follow these steps:
mkdir a
mkdir a/k
mkdir a/l
mkdir a/k/x
mkdir a/k/y
cd a
ln -s k/y link-y
ls link-y/..
This outputs: x/ y/
In other words, link-y/.. == a/k
Now, while still in directory 'a' (in bash) execute on
one line:
python -c 'import os.path'$'\n''print
os.path.realpath("link-y/..")'
This will print: /path/to/a
In other words: os.path.realpath('link-y/..') == a
That is, the link link-y has not been expanded to the
directory it points to before .. (go to parent
directory) has been applied to the path.
os.path.normpath() has the same problem.
This may be a potential security risk if one uses
realpath to check if a requested path is inside a
certain restricted subdirectory.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=990669&group_id=5470
More information about the Python-bugs-list
mailing list