Bug 492908 - $RANDOM value remains the same
Summary: $RANDOM value remains the same
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: bash
Version: 5.3
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Roman Rakus
QA Contact: BaseOS QE
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-03-30 17:08 UTC by Jaroslav Kortus
Modified: 2014-01-13 00:08 UTC (History)
4 users (show)

Fixed In Version: bash-3.2-27.el5
Doc Type: Bug Fix
Doc Text:
The $RANDOM variable in Bash carried over values from a previous execution for later jobs. This is fixed and the $RANDOM variable generates a new random number for each use.
Clone Of:
Environment:
Last Closed: 2011-07-21 10:38:30 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Patch for RNG (1.52 KB, patch)
2011-01-19 08:08 UTC, Roman Rakus
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2011:1073 0 normal SHIPPED_LIVE Low: bash security, bug fix, and enhancement update 2011-07-21 10:37:04 UTC

Description Jaroslav Kortus 2009-03-30 17:08:42 UTC
Description of problem:
bash $RANDOM value remains the same after first usage with "-$RANDOM"

Version-Release number of selected component (if applicable):
bash-3.2-24.el5
GNU bash, version 3.2.25(1)-release (ia64-redhat-linux-gnu)

How reproducible:
100%

Steps to Reproduce:
1. for i in 1 2 3; do echo $RANDOM >> /tmp/random.txt& sleep 1; done
2. cat /tmp/random.txt (3 different numbers)
3. echo -$RANDOM
4. for i in 1 2 3; do echo $RANDOM >> /tmp/random.txt& sleep 1; done
5. cat /tmp/random.txt (3 different numbers from 1st run, 3 times one number from the 2nd one)
  
Actual results:
$RANDOM value is the same for every background command invocation 

Expected results:
$RANDOM value should be random each time

Additional info:

Comment 1 Roman Rakus 2009-03-31 13:50:36 UTC
This is similar to bug 344411. Backporting patch will fix it.

Comment 2 RHEL Program Management 2009-11-06 18:58:57 UTC
This request was evaluated by Red Hat Product Management for
inclusion, but this component is not scheduled to be updated in
the current Red Hat Enterprise Linux release. If you would like
this request to be reviewed for the next minor release, ask your
support representative to set the next rhel-x.y flag to "?".

Comment 4 RHEL Program Management 2010-08-09 19:06:17 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated in the
current release, Red Hat is unfortunately unable to address this
request at this time. Red Hat invites you to ask your support
representative to propose this request, if appropriate and relevant,
in the next release of Red Hat Enterprise Linux.

Comment 5 Roman Rakus 2011-01-19 08:08:13 UTC
Created attachment 474216 [details]
Patch for RNG

Comment 6 Roman Rakus 2011-02-21 16:38:22 UTC
Fixed in bash-3.2-27.el5

Comment 8 Branislav Náter 2011-04-15 11:04:26 UTC
Bugfix verified on bash-3.2-29.el5 package on all supported architectures.

$RANDOM value is now random also after usage of "-$RANDOM".

Comment 9 Misha H. Ali 2011-04-20 09:02:07 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
The $RANDOM variable in Bash retained the number during jobs executed in the background. This is now fixed to ensure that the $RANDOM variable always generates a new random number.

Comment 10 Misha H. Ali 2011-04-20 09:37:57 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-The $RANDOM variable in Bash retained the number during jobs executed in the background. This is now fixed to ensure that the $RANDOM variable always generates a new random number.+The $RANDOM variable in Bash retained the value from a previous execution for later jobs that executed in the background. This is now fixed to ensure that the $RANDOM variable always generates a new random number.

Comment 11 Misha H. Ali 2011-04-21 00:13:14 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-The $RANDOM variable in Bash retained the value from a previous execution for later jobs that executed in the background. This is now fixed to ensure that the $RANDOM variable always generates a new random number.+The $RANDOM variable in Bash carried over the last generated value from a previous execution for later jobs that executed in the background. This is now fixed to ensure that the $RANDOM variable contains a new random number for each use.

Comment 12 Misha H. Ali 2011-05-04 01:35:06 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-The $RANDOM variable in Bash carried over the last generated value from a previous execution for later jobs that executed in the background. This is now fixed to ensure that the $RANDOM variable contains a new random number for each use.+The $RANDOM variable in Bash carried over values from a previous execution for later jobs. This is fixed and the $RANDOM variable generates a new random number for each use.

Comment 13 errata-xmlrpc 2011-07-21 10:38:30 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/RHSA-2011-1073.html


Note You need to log in before you can comment on or make changes to this bug.