Bug 1245302

Summary: Running 'rescan-scsi-bus -u' deletes /dev/null
Product: Red Hat Enterprise Linux 6 Reporter: John Pittman <jpittman>
Component: sg3_utilsAssignee: David Sommerseth <davids>
Status: CLOSED ERRATA QA Contact: Jan Kepler <jkejda>
Severity: medium Docs Contact: Petr Bokoc <pbokoc>
Priority: medium    
Version: 6.6CC: amote, bhaubeck, bubrown, dkutalek, jkejda, jmagrini, mkolaja, ovasik, pbokoc
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
"rescan-scsi-bus.sh" no longer removes `/dev/null` When running the "rescan-scsi-bus.sh" script, due to incorrect syntax in redirecting output to the `/dev/null` device file while executing the `/bin/rm` utility, the redirection did not happen but `/dev/null` was instead interpreted as a file to be removed. As a consequence, running "rescan-scsi-bus.sh" with the "--update" option removed `/dev/null` during execution. This bug has been fixed, and /dev/null is no longer removed by "rescan-scsi-bus.sh".
Story Points: ---
Clone Of:
: 1298737 1300338 (view as bug list) Environment:
Last Closed: 2016-05-11 00:29:52 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:
Bug Depends On:    
Bug Blocks: 1172231, 1254457, 1298737, 1300338    
Attachments:
Description Flags
proposed patches for RHEL6 and 7
none
Fix /dev/null redirect mistakes none

Description John Pittman 2015-07-21 17:27:10 UTC
Description of problem:

When running the command 'rescan-scsi-bus.sh -u' the /dev/null file will be deleted.

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

sg3_utils-1.28-6.el6.x86_64
sg3_utils-libs-1.28-6.el6.x86_64

2.6.32-504.16.2.el6.x86_64

Issue also present in RHEL7 at levels:

sg3_utils-libs-1.37-5.el7.x86_64
sg3_utils-1.37-5.el7.x86_64
3.10.0-229.el7.x86_64

How reproducible:

[root@rhel6a ~]# cat test.sh 
#/bin/bash

rm tmp.out 2&>1 /dev/null

[root@rhel6a ~]# touch tmp.out

[root@rhel6a ~]# ls /dev | grep null
null

[root@rhel6a ~]# ./test.sh
[root@rhel6a ~]#

[root@rhel6a ~]# ls | grep tmp.out
[root@rhel6a ~]#

[root@rhel6a ~]# ls /dev | grep null
[root@rhel6a ~]# 

[root@rhel6a ~]# udevadm trigger
[root@rhel6a ~]# 

[root@rhel6a ~]# ls /dev | grep null
null

Actual results:

The following on line 725 removes /dev/null because of the 2&>1

rm $tmpfile 2&>1 /dev/null

The set -x output shows:

+ rm /tmp/rescan-scsi-bus-s 2 /dev/null

* Issue does not reproduce if I change 2&>1 to either of the following:

2>
&>

* It does reproduce if I use 2>&1.

Expected results:

/dev/null not be deleted.

If I can be of any help please let me know.

John

Comment 2 John Pittman 2015-07-21 20:36:50 UTC
Created attachment 1054528 [details]
proposed patches for RHEL6 and 7

Comment 4 David Sommerseth 2015-12-18 18:28:03 UTC
Created attachment 1107282 [details]
Fix /dev/null redirect mistakes

Updated the proposed patches with the new attachment (0001-Fix-dev-null-redirect-mistakes.patch), plus submitted it upstream.

Scratch build available here: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=10254401
Will wait for a final build when more issues from other bzs have considered.

Comment 10 errata-xmlrpc 2016-05-11 00:29:52 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.

https://rhn.redhat.com/errata/RHBA-2016-0905.html