diff options
author | Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> | 2015-07-06 11:55:13 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2015-07-06 11:55:13 +0100 |
commit | ab55d60518e3885b73de0f2a3d6258f38d956ab4 (patch) | |
tree | 837b15b073d1941b20e69eac601881475b699a9a /pylintrc | |
parent | 7e9cf868194105fb2a007ca51801e7d5c31f38c5 (diff) | |
download | sos-ab55d60518e3885b73de0f2a3d6258f38d956ab4.tar.gz |
[plugin] fix recursive symlink handling
A symbolic link that points to itself may exist in paths encountered
as part of a copyspec. For a normal symlink the link target is added
to the set of paths to collect. For a link pointing to itself, we end
up in recursive loop. Avoid this by skipping the path collection for
the target in the case that the canonicalized target and link path
are equal.
For example:
total 0
0 lrwxrwxrwx. 1 root root 14 May 18 09:22 default.xml -> ../default.xml
0 lrwxrwxrwx. 1 root root 7 May 22 05:37 kop.xml -> kop.xml
Trying to copying such symlink, will ends up in following exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1172,
in collect
plug.collect()
File "/usr/lib/python2.7/site-packages/sos/plugins/__init__.py", line
630, in collect
self._collect_copy_specs()
File "/usr/lib/python2.7/site-packages/sos/plugins/__init__.py", line
600, in _collect_copy_specs
self._do_copy_path(path)
File "/usr/lib/python2.7/site-packages/sos/plugins/__init__.py", line
319, in _do_copy_path
self._copy_symlink(srcpath)
File "/usr/lib/python2.7/site-packages/sos/plugins/__init__.py", line
271, in _copy_symlink
self._do_copy_path(absdest)
File "/usr/lib/python2.7/site-packages/sos/plugins/__init__.py", line
319, in _do_copy_path
self._copy_symlink(srcpath)
File "/usr/lib/python2.7/site-packages/sos/plugins/__init__.py", line
261, in _copy_symlink
self.archive.add_link(reldest, srcpath)
File "/usr/lib/python2.7/site-packages/sos/archive.py", line 198, in
add_link
os.symlink(source, dest)
OSError: [Errno 17] File exists
Fix this recursive loop but just creating the link and skip copying
the symlink.
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
(minor edits to debug and commit message)
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
v2:
- Create the link and skip copying, if both src and dest are same.
- Append the symlink to files, copied list.
v1:
Initial version: Returns, if the source path does not exist.
sos/plugins/__init__.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
Diffstat (limited to 'pylintrc')
0 files changed, 0 insertions, 0 deletions