"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".
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
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.
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