Bug 144331

Summary: mkinitrd fails with noclobber set in shell
Product: [Fedora] Fedora Reporter: Joshua Buysse <buysse>
Component: mkinitrdAssignee: Peter Jones <pjones>
Status: CLOSED RAWHIDE QA Contact: David Lawrence <dkl>
Severity: high Docs Contact:
Priority: medium    
Version: 3CC: pakrat-rhat2
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-03-23 22:22:59 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:
Attachments:
Description Flags
Patch to mkinitrd that does 'set +o noclobber' none

Description Joshua Buysse 2005-01-06 02:02:42 UTC
Description of problem:

The mkinitrd command fails to create a new image if noclobber is set
in the shell.

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

How reproducible: 
  Every time.

Steps to Reproduce:
1. set -o noclobber
2. mkinitrd $version.img $version
  
Actual results:
  /sbin/mkinitrd: line 776: /tmp/initrd.img.xv5505: cannot overwrite
existing file.

  No image created.

Expected results:
  No output, rd image created.

Additional info:
  Same problem as bug 144053 (groff, man fails if noclobber set).

Comment 1 Peter Jones 2005-03-07 22:46:17 UTC
I'll happily take a patch to fix this.  Unless somebody provides one, I don't
think it's worth the trouble to fix.

Comment 2 Joshua Buysse 2005-03-07 22:55:44 UTC
Created attachment 111759 [details]
Patch to mkinitrd that does 'set +o noclobber'

Comment 3 Chris Dukes 2005-03-08 17:58:38 UTC
Your patch fixes the symptoms without neccesarily fixing the root cause of the
problem.
1) Are you really doing 'set -o noclobber' from the shell, or are you doing it
from $BASH_ENV or something called by $BASH_ENV?  If so, you can reasonably
expect to clobber any /bin/bash script.
2) Is bash inheriting 'set -o noclobber'?

Try this test script
cat > /tmp/ts <<EEOOFF
#!/bin/bash -x
\echo BASH_ENV="'$BASH_ENV'"
\set -o | /bin/grep clobber
EEOOFF
Try running 'set -o noclobber;/tmp/ts' and 'set +o noclobber;/tmp/ts'.
If the script is inheriting the setting, double check to see if this is current
correct behavior.  If not, open the bug against 'bash'.
If 'set -o noclobber' is being set by $BASH_ENV you should consider one of the
following.
1) Use ~/.bashrc for interactive shells.
2) Use a case $- in; *i*) .... ;; esac construct to only set noclobber for
interactive shells
3) Accept that your choice of $BASH_ENV over ~/.bashrc is going to skew behavior
 of bash scripts.

Red Hat,
I strongly recommend that you audit your #!/bin/bash scripts to see if they run
correctly with the 'dash' posix shell.  If so, change #!/bin/bash to #!/bin/sh t
his will remove the possibility of $BASH_ENV overriding default behavior. If
bashisms are present, re-evaluate whether or not they are appropriate to the task.


Comment 4 Peter Jones 2005-03-23 22:22:59 UTC
Fixed in rawhide.