Bug 454690

Summary: sysreport.legacy reports "Cannot make temp dir"
Product: Red Hat Enterprise Linux 4 Reporter: Bryan Mason <nobody+bjmason>
Component: sosAssignee: Adam Stokes <astokes>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 4.6CC: agk, azelinka, bmason, bmr, bressers, duck, rbiba, rlerch, tao
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
* sysreport.legacy used $HOME as its root directory. In case this environment variable did not exist or the directory it referred to was not writable, sysreport.legacy could not generate its report and would exit with the message "Cannot make temp dir". Sysreport.legacy now uses a randomly created directory as its root directory and therefore can generate a report even on a system without a usable $HOME.
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-05-18 20:24:13 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 391511, 458752, 467444    
Attachments:
Description Flags
Proposed patch
none
Updated patch
none
Corrected updated patch none

Description Bryan Mason 2008-07-09 19:03:55 UTC
+++ This bug was initially created as a clone of Bug #445947 +++

Description of problem:

    Because sysreport.legacy uses $HOME as it's root directory, problems
    can occur if $HOME doesn't exist or isn't writable.

Version-Release number of selected component (if applicable):

    sos-1.7-9.2.el5.noarch

How reproducible:

    Every time, if the home directory doesn't exist.

Steps to Reproduce:

    1. Log into a system using an account that has no local home directory.
    2. Run sysreport.legacy as root using sudo.
  
Actual results:

    $ sudo /usr/sbin/sysreport.legacy
    Password:
    Cannot make temp dir

Expected results:

    Sysreport generated.

Additional info:

    This is actually the same problem reported in Bug 355071, but that report
    was for sysreport and this is reported against sysreport.legacy.

Comment 1 Bryan Mason 2008-07-09 19:04:48 UTC
Created attachment 311404 [details]
Proposed patch

Create a new variable named TEMP='/tmp' and replace occurrences of $HOME with
$TEMP.

Comment 2 RHEL Program Management 2008-09-05 17:23:21 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 3 Josh Bressers 2008-09-30 16:51:51 UTC
That patch looks dangerous.  I'd suggest you simply something like
TEMP=`mktemp -d`

Then just remove $TEMP at the end of the run.

As it stands, the patch will likely introduce a security flaw.

Comment 8 Bryan Mason 2008-10-16 23:07:54 UTC
(In reply to comment #3)
> That patch looks dangerous.  I'd suggest you simply something like
> TEMP=`mktemp -d`
> 
> Then just remove $TEMP at the end of the run.

But we can't remove $TEMP at the end of the run because the output file is located in $TEMP/${NAME}.${SUFFIX} (used to be $HOME/${NAME}.${SUFFIX} before we started using a temp dir instead of /root to hold the sysreport files).

Comment 9 Bryan Mason 2008-10-16 23:11:06 UTC
Created attachment 320620 [details]
Updated patch

Uses `mktemp -d` to create the $TEMP directory.

Comment 10 Bryan Mason 2008-10-17 00:43:43 UTC
Created attachment 320623 [details]
Corrected updated patch

You'd think after all these years, I'd know the difference between '\' and '/'. :^)

Comment 14 Ruediger Landmann 2009-01-29 06:23:43 UTC
Release note added. If any revisions are required, please set the 
"requires_release_notes" flag to "?" and edit the "Release Notes" field accordingly.
All revisions will be proofread by the Engineering Content Services team.

New Contents:
* sysreport.legacy used $HOME as its root directory. On systems that did not have a local home directory, sysreport.legacy could not generate its report and would exit with the message "Cannot make temp dir". Sysreport.legacy now uses /bin as its root directory and therefore can generate a report even on a system without a local home directory.

Comment 15 Radek Bíba 2009-01-29 09:01:39 UTC
Release note updated. If any revisions are required, please set the 
"requires_release_notes"  flag to "?" and edit the "Release Notes" field accordingly.
All revisions will be proofread by the Engineering Content Services team.

Diffed Contents:
@@ -1 +1 @@
-* sysreport.legacy used $HOME as its root directory. On systems that did not have a local home directory, sysreport.legacy could not generate its report and would exit with the message "Cannot make temp dir". Sysreport.legacy now uses /bin as its root directory and therefore can generate a report even on a system without a local home directory.+* sysreport.legacy used $HOME as its root directory. In case this environment variable did not exist or the directory it referred to was not writable, sysreport.legacy could not generate its report and would exit with the message "Cannot make temp dir". Sysreport.legacy now uses a randomly created directory as its root directory and therefore can generate a report even on a system without a usable $HOME.

Comment 21 errata-xmlrpc 2009-05-18 20:24:13 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2009-0994.html