Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 597279

Summary: anaconda crashes with non-existing directory in %pre --log parameter
Product: Red Hat Enterprise Linux 6 Reporter: Alexander Todorov <atodorov>
Component: anacondaAssignee: Dave Cantrell <dcantrell>
Status: CLOSED CURRENTRELEASE QA Contact: Release Test Team <release-test-team-automation>
Severity: high Docs Contact:
Priority: high    
Version: 6.0CC: atodorov, james.leddy, jbastian, rlerch, tao
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: anaconda-13.21.51-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 568861 Environment:
Last Closed: 2010-11-10 19:46:19 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: 568861    
Bug Blocks: 582286    

Description Alexander Todorov 2010-05-28 14:52:55 UTC
When --log parameter for %pre script is a path which includes non-existing directory anaconda will crash.

Running anaconda 13.21.48, the Red Hat Enterprise Linux system installer - please wait.
Traceback (most recent call last):
  File "/usr/bin/anaconda", line 825, in <module>
    kickstart.preScriptPass(anaconda, opts.ksfile)
  File "/usr/lib/anaconda/kickstart.py", line 1225, in preScriptPass
    runPreScripts(anaconda, ksparser.handler.scripts)
  File "/usr/lib/anaconda/kickstart.py", line 1309, in runPreScripts
    map (lambda s: s.run("/", flags.serial, anaconda.intf), preScripts)
  File "/usr/lib/anaconda/kickstart.py", line 1309, in <lambda>
    map (lambda s: s.run("/", flags.serial, anaconda.intf), preScripts)
  File "/usr/lib/anaconda/kickstart.py", line 94, in run
    root = scriptRoot)
  File "/usr/lib/anaconda/iutil.py", line 96, in execWithRedirect
    stdout = os.open(stdout, os.O_RDWR|os.O_CREAT)
OSError: [Errno 2] No such file or directory: '/tmp/non-existing/pre_non_existing.log'
install exited abnormally [1/1] 
The system will be rebooted when you press Ctrl-C or Ctrl-Alt-Delete.

Version:
anaconda 13.21.48


How reproducible:
Always

Steps to reproduce:
use /distribution/install/scripts-logging test case or this ks.cfg:

%pre --logfile /tmp/pre_existing.log

echo "LOG TEST: %pre script that logs to a file in existing directory"
%end

%pre --logfile /tmp/non-existing/pre_non_existing.log

echo "LOG TEST: %pre script that logs to a file in non-existing directory"
%end

%post --logfile /root/post_chroot_existing.log

echo "LOG TEST: %post script inside chroot that logs to a file in existing directory"
%end

%post --logfile /root/non-existing/post_chroot_non_existing.log

echo "LOG TEST: %post script inside chroot that logs to a file in non-existing directory"
%end

%post --nochroot --logfile /mnt/sysimage/root/post_no_chroot_existing_under_sysimage.log

echo "LOG TEST: %post script outside chroot that logs to a file in existing directory under /mnt/sysimage"
%end

%post --nochroot --logfile /mnt/sysimage/root/non-existing-under-sysimage/post_no_chroot_non_existing_under_sysimage.log

echo "LOG TEST: %post script outside chroot that logs to a file in non-existing directory under /mnt/sysimage"
%end

%post --nochroot --logfile /tmp/post_no_chroot_existing_outside_sysimage.log

echo "LOG TEST: %post script outside chroot that logs to a file in existing directory outside /mnt/sysimage"
%end

%post --nochroot --logfile /tmp/non-existing-outside-sysimage/post_no_chroot_non_existing_outside_sysimage.log

echo "LOG TEST: %post script outside chroot that logs to a file in non-existing directory outside /mnt/sysimage"
%end

Comment 2 Dave Cantrell 2010-05-28 21:15:11 UTC
Simple patch:

diff --git a/iutil.py b/iutil.py
index a568ff7..d0f6212 100644
--- a/iutil.py
+++ b/iutil.py
@@ -93,6 +93,9 @@ def execWithRedirect(command, argv, stdin = None, stdout = Non
         stdin = sys.stdin.fileno()
 
     if isinstance(stdout, str):
+        dn = os.path.dirname(os.path.realpath(stdout))
+        if not os.path.isdir(dn):
+            os.makedirs(dn)
         stdout = os.open(stdout, os.O_RDWR|os.O_CREAT)
         stdoutclose = lambda : os.close(stdout)
     elif isinstance(stdout, int):

Comment 3 Dave Cantrell 2010-05-28 21:17:51 UTC
Can you try using updates=http://dcantrel.fedorapeople.org/updates/597279.img and see if it solves the problem?

Comment 4 Alexander Todorov 2010-05-31 12:25:15 UTC
David,
I've tried with the updates.img and it solved the problem. In my test I have severap %pre/%post scripts that log into various locations in existing and non-existing directories. All scripts worked.

Comment 7 releng-rhel@redhat.com 2010-11-10 19:46:19 UTC
Red Hat Enterprise Linux 6.0 is now available and should resolve
the problem described in this bug report. This report is therefore being closed
with a resolution of CURRENTRELEASE. You may reopen this bug report if the
solution does not work for you.