Bug 888724
| Summary: | sos does not preserve permissions on collected files | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 6 | Reporter: | Bryn M. Reeves <bmr> |
| Component: | sos | Assignee: | Bryn M. Reeves <bmr> |
| Status: | CLOSED ERRATA | QA Contact: | Filip Holec <fholec> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 6.4 | CC: | agk, ahecox, bmr, dkutalek, fholec, gavin, jentrena, lyarwood, myllynen, psplicha, sos-team |
| Target Milestone: | rc | Keywords: | EasyFix, Patch |
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | sos-2.2-42.el6 | Doc Type: | Bug Fix |
| Doc Text: |
Cause:
Previous versions of sos failed to preserve the permissions of files collected from the host file system.
Consequence:
Permission information in sosreport archives is inconsistent with permissions on the host system potentially misleading users.
Fix:
Permissions data is now copied for all files copied from the host file system.
Result:
Permissions reflected in sosreport archives now match those reported on the host system.
|
Story Points: | --- |
| Clone Of: | Environment: | ||
| Last Closed: | 2013-11-21 22:37:29 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
|
Description
Bryn M. Reeves
2012-12-19 10:46:10 UTC
commit 2ab4529daad2fd133d91379ce94a297d037fd372
Author: Bryn M. Reeves <bmr>
Date: Wed Dec 19 21:06:19 2012 +0000
Preserve ownership and permission on copied files
Preserve the ownership and permission information for collected
files by using shutil.copy2 instead of copyfileobj() and calling
os.chown() after copying.
diff --git a/sos/plugintools.py b/sos/plugintools.py
index 39b2368..ea29ea9 100644
--- a/sos/plugintools.py
+++ b/sos/plugintools.py
@@ -232,11 +232,9 @@ class PluginBase:
linkto = os.readlink(src)
os.symlink(linkto, new_fname)
else:
- fsrc = open(src,'r')
- fdst = open(new_fname, 'w')
- shutil.copyfileobj(fsrc, fdst, -1)
- fsrc.close()
- fdst.close()
+ shutil.copy2(src, new_fname)
+ stat = os.stat(src)
+ os.chown(new_fname, stat.st_uid, stat.st_gid)
else:
raise PluginException('Error copying file: already exists')
*** Bug 1003550 has been marked as a duplicate of this bug. *** Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2013-1688.html |