[sos-devel] [PATCH] plugins/__init__.py: Skip copying of broken symlink

Bryn M. Reeves bmr at redhat.com
Tue May 26 09:56:34 UTC 2015


On Tue, May 26, 2015 at 01:27:43PM +0530, Kamalesh Babulal wrote:
> Check if the srcpath exist before creating the symlink in
> __copy_symlink(), so we could avoid trying to link from broken
> (not existing) source.

Please make sure to explain problems in enough detail that another
user can re-create the problem and test your fix. The symlink code
is designed to work correctly with broken symlinks (we want to
include them in the report as they carry diagnostic value - i.e. a
symlink is broken on the target system).

The patch breaks this as it skips all symlinks where the link
target is non-existent.

> This patch fixes the following issue:
> 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]

Are you sure you don't have a symlink that points to itself here?

That should be the only explanation for:

  _copy_symlink() -> _do_copy_path() -> _copy_symlink()

The patch should test that linkdest == srcpath (using canonical paths as
appropriate), create the link appropriately (it should anyway) and then
skip collection of the target since it is already present.

Regards,
Bryn.




More information about the sos-devel mailing list