Bug 966602

Summary: potential data loss when TAPE is set
Product: Red Hat Enterprise Linux 6 Reporter: Bryn M. Reeves <bmr>
Component: sosAssignee: Bryn M. Reeves <bmr>
Status: CLOSED ERRATA QA Contact: Filip Holec <fholec>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 6.4CC: agk, bmr, dkutalek, fholec, gavin, psplicha, sos-team
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: sos-2.2-39.el6 Doc Type: Bug Fix
Doc Text:
Cause: The sosreport command incorrectly assumes that the tar program will always default to writing data on standard output. This is not the case when the environment variable TAPE is set. Consequence: Data may be unexpectedly written to a tape device, or another location, expanded to by the TAPE environment variable. Fix: The sosreport command now always calls tar with the '-f-' option to force data to be written to standard output. Result: The location to which sos writes data is no longer influenced by the TAPE environment variable. Users who set this variable in their environment can run sosreport without risking overwriting data on existing tape devices.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-11-21 22:39: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 2013-05-23 14:24:01 UTC
Description of problem:
The tar invocation used by sos is effectively:

  tar -c $PATH | $COMPRESS > $OUTPUT_FILE

This is vulnerable to unexpected behaviour when the user has set the TAPE environment variable to some tape device in the system. Depending on the state of the device this could interfere with normal tape operations or corrupt data that is already present on the tape device.

Version-Release number of selected component (if applicable):
sos-2.2-*.el6

How reproducible:
100%

Steps to Reproduce:
Without a tape device present:
1. # file /dev/st0
/dev/st0: cannot open `/dev/st0' (No such file or directory)
2. # TAPE="/dev/st0" sosreport --batch -o general
3. # file /dev/st0

Actual results:
# file /dev/st0
/dev/st0: POSIX tar archive (GNU)

No sosreport is generated in TMP.

Expected results:
# file /dev/st0
/dev/st0: cannot open `/dev/st0' (No such file or directory)

An sosreport is generated in TMP.

Additional info:
sos should always use '-f-' to explicitly write the archive to stdout.

Comment 1 Bryn M. Reeves 2013-05-23 14:50:40 UTC
https://github.com/sosreport/sosreport/commit/3b868b2

Comment 6 errata-xmlrpc 2013-11-21 22:39:29 UTC
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