Bug 568861 - [RHEL 5.5 Beta] anaconda crashes with full path specified in %post --log parameter
[RHEL 5.5 Beta] anaconda crashes with full path specified in %post --log para...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: anaconda (Show other bugs)
5.5
All Linux
high Severity high
: rc
: ---
Assigned To: David Cantrell
Release Test Team
: Regression
Depends On:
Blocks: 5.5_Known-Issues 597279
  Show dependency treegraph
 
Reported: 2010-02-26 13:54 EST by Jeff Bastian
Modified: 2013-07-11 20:03 EDT (History)
6 users (show)

See Also:
Fixed In Version: anaconda-11.1.2.213-1
Doc Type: Bug Fix
Doc Text:
Prior to Red Hat Enterprise Linux 5.5, the --log option in anaconda was not aware of whether %pre and %post scripts in kickstart files were running in a chroot environment or not. Therefore, kickstart files had to provide absolute paths to log files. Improvements to anaconda in Red Hat Enterprise Linux 5.5 made the --log option aware of chroot environments. Consequently, if unmodified kickstart files from Red Hat Enterprise Linux 5.4 were used to install Red Hat Enterprise Linux 5.5, anaconda sometimes crashed and reported that the directory did not exist. The --log option is now further modified to accept either absolute or relative paths. The presence of absolute paths does not prevent the use of kickstart files created for earlier versions of Red Hat Enterprise Linux 5.
Story Points: ---
Clone Of:
: 597279 (view as bug list)
Environment:
Last Closed: 2011-01-13 16:54:28 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
path to strip '/mnt/sysimage' (897 bytes, patch)
2010-02-26 14:04 EST, Jeff Bastian
no flags Details | Diff

  None (edit)
Description Jeff Bastian 2010-02-26 13:54:54 EST
Description of problem:
With RHEL 5.4 and earlier, to save the output of a %post script in a log file, the kickstart file would specify the full path from outside the chroot jail, for example:
   %post --log=/mnt/sysimage/root/ks-post.log

This causes RHEL 5.5 Beta to crash with the error
IOError: [Errno 2] No such file or directory: '/mnt/sysimage//mnt/sysimage/root/
install.logs/install.post.gslog'

This is due to the changes from bug 510636 comment 8.  The new method is one of
   %post --log=/root/ks-post.log
   %post --nochroot --log=/mnt/sysimage/root/ks-post.log

This breaks kickstart files for RHEL 5.0 through 5.4.

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

How reproducible:
every time

Steps to Reproduce:
1. install RHEL 5.5 Beta with a kickstart file that contains
      %post --log=/mnt/sysimage/root/ks-post.log
      echo "Running post script"
  
Actual results:
anaconda crashes

Expected results:
anaconda gracefully handles the problem

Additional info:
http://git.fedoraproject.org/git/?p=anaconda.git;a=commitdiff;h=17149c7b698132d567f84d81be5f377bfbf04b3b;hp=ee53c0fef1977811ad30d5f8cab83ba3afdd1a2e
Comment 1 Jeff Bastian 2010-02-26 13:57:54 EST
Full anaconda traceback:

Traceback (most recent call first):
 File "/usr/lib/anaconda/iutil.py", line 45, in execWithRedirect
   stdout = open(stdout, "w")
 File "/usr/lib/anaconda/kickstart.py", line 75, in run
   root = scriptRoot)
 File "/usr/lib/anaconda/kickstart.py", line 901, in <lambda>
   map (lambda s: s.run(anaconda.rootPath, serial, anaconda.intf), postScripts)
 File "/usr/lib/anaconda/kickstart.py", line 901, in postAction
   map (lambda s: s.run(anaconda.rootPath, serial, anaconda.intf), postScripts)
 File "/usr/lib/anaconda/packages.py", line 44, in doPostAction
   anaconda.id.instClass.postAction(anaconda, flags.serial)
 File "/usr/lib/anaconda/dispatch.py", line 204, in moveStep
   rc = stepFunc(self.anaconda)
 File "/usr/lib/anaconda/dispatch.py", line 127, in gotoNext
   self.moveStep()
 File "/usr/lib/anaconda/cmdline.py", line 146, in run
   anaconda.dispatch.gotoNext()
 File "/usr/bin/anaconda", line 974, in ?
   anaconda.intf.run(anaconda)
IOError: [Errno 2] No such file or directory: '/mnt/sysimage//mnt/sysimage/root/
ks-post.log'

Local variables in innermost frame:
searchPath: 0
stdout: /mnt/sysimage//mnt/sysimage/root/ks-post.log
stdin: 0
argv: ['/tmp/ks-script-42QHgs']
chroot: <function chroot at 0x1fbcc0c8>
command: /bin/sh
stderr: /mnt/sysimage//mnt/sysimage/root/ks-post.log
root: /mnt/sysimage
Comment 2 Jeff Bastian 2010-02-26 14:04:51 EST
Created attachment 396631 [details]
path to strip '/mnt/sysimage'

One possible method to make anaconda gracefully handle kickstart files with /mnt/sysimage in the path is to strip it from the path if it's there.  The attached patch does this.

Of course, this could introduce a new bug if someone intentionally wants a /mnt/sysimage within the /mnt/sysimage chroot jail.  That is, /mnt/sysimage/mnt/sysimage is the path from outside the jail.
Comment 3 Chris Lumens 2010-02-26 14:16:32 EST
> With RHEL 5.4 and earlier, to save the output of a %post script in a log file,
> the kickstart file would specify the full path from outside the chroot jail,
> for example:
>    %post --log=/mnt/sysimage/root/ks-post.log

I'd argue that this was broken behavior in 5.4 and earlier - logs should take the chroot into account just like everything else about kickstart scripts.

> This causes RHEL 5.5 Beta to crash with the error
> IOError: [Errno 2] No such file or directory:
> '/mnt/sysimage//mnt/sysimage/root/
> install.logs/install.post.gslog'

However, this is bad.  We should definitely be handling the case where the containing directory does not first exist.  In fact the patch was intended to do that, except that I used basename instead of dirname at kickstart.py:65.
Comment 6 Issue Tracker 2010-02-26 14:43:48 EST
Event posted on 02-26-2010 02:40pm EST by jleddy

Hi Jeff,

I meant to comment on this bug earlier, but lost track of time. I don't
disagree that the 5.4 behavior was a bug, but it wasn't documented as
such. The impressionis that using /mnt/sysimage as documented, and that
there isn't any documenting to address this change. 

My other concern is that I initially thought the directory was not
created, but if you look at the code there is clearly the os.makedirs
call. How is it possible that this is throwing "No such file or
directory"?


This event sent from IssueTracker by jleddy 
 issue 566533
Comment 7 Jeff Bastian 2010-02-26 14:57:03 EST
(copying response from issue tracker)

(In reply to comment #6)
> ...there is clearly the os.makedirs call. How is it possible that this is
> throwing "No such file or directory"?

This is what Chris mentioned in comment 3 about using basename instead of dirname:
 65             d = os.path.basename(messages)
 66             if not os.path.exists(d):
 67                 os.makedirs(d)

basename returns the filename, not the directories, so it was essentially running os.makedirs("ks-post.log")
Comment 9 Jeff Bastian 2010-02-26 15:14:04 EST
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:
Cause
=====
In Red Hat Enterprise Linux 5.5, anaconda was improved to provide better logging of errors while running %pre and %post scripts in kickstart files.  As part of this improvement, the --log option is now aware if the %post script is running in a chroot environment or not.

Consequence
===========
The full path to the log file needs to take into account if the script is running in a chroot environment.  These are equivalent:
   %post --log=/root/ks-post.log
   %post --nochroot --log=/mnt/sysimage/root/ks-post.log

Change
======
In RHEL 5.4 and earlier, the --log option always required the path to contain /mnt/sysimage for the logs to be saved on the system.  In RHEL 5.5, you should only specify /mnt/sysimage if using the --nochroot option also.

Result
======
If unmodified kickstart files from RHEL 5.4 are used to install RHEL 5.5, the log files will be saved in an unexpected location.  For example, if the kickstart file contains
   %post --nochroot --log=/mnt/sysimage/root/ks-post.log
then the ks-post.log will be found in /mnt/sysimage/root, not /root, after installation is complete.
Comment 10 James M. Leddy 2010-02-26 15:33:38 EST
(In reply to comment #7)
> basename returns the filename, not the directories, so it was essentially
> running os.makedirs("ks-post.log")    

Ah this makes sense. With this fixed anyone should be able to install in any case. It was the crashing Anaconda for using '/mnt/sysimage' that causes a lot of hurt.
Comment 14 Jeff Bastian 2010-02-26 17:23:54 EST
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:
@@ -14,6 +14,4 @@
 
 Result
 ======
-If unmodified kickstart files from RHEL 5.4 are used to install RHEL 5.5, the log files will be saved in an unexpected location.  For example, if the kickstart file contains
+If unmodified kickstart files from RHEL 5.4 are used to install RHEL 5.5, anaconda may crash and complain that the directory does not exist.  This is a known issue and may be fixed in a future update of RHEL.-   %post --nochroot --log=/mnt/sysimage/root/ks-post.log
-then the ks-post.log will be found in /mnt/sysimage/root, not /root, after installation is complete.
Comment 18 Ludek Smid 2010-03-11 07:17:01 EST
Since it is too late to address this issue in RHEL 5.5, it has been proposed for RHEL 5.6.  Contact your support representative if you need to escalate this issue.
Comment 20 Ryan Lerch 2010-03-28 18:25:35 EDT
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,17 +1 @@
-Cause
+If unmodified kickstart files from Red Hat Enterprise Linux 5.4 are used to install Red Hat Enterprise Linux 5.5, anaconda may crash and complain that the directory required to save the log files does not exist.(BZ#568861)-=====
-In Red Hat Enterprise Linux 5.5, anaconda was improved to provide better logging of errors while running %pre and %post scripts in kickstart files.  As part of this improvement, the --log option is now aware if the %post script is running in a chroot environment or not.
-
-Consequence
-===========
-The full path to the log file needs to take into account if the script is running in a chroot environment.  These are equivalent:
-   %post --log=/root/ks-post.log
-   %post --nochroot --log=/mnt/sysimage/root/ks-post.log
-
-Change
-======
-In RHEL 5.4 and earlier, the --log option always required the path to contain /mnt/sysimage for the logs to be saved on the system.  In RHEL 5.5, you should only specify /mnt/sysimage if using the --nochroot option also.
-
-Result
-======
-If unmodified kickstart files from RHEL 5.4 are used to install RHEL 5.5, anaconda may crash and complain that the directory does not exist.  This is a known issue and may be fixed in a future update of RHEL.
Comment 21 Chris Lumens 2010-06-02 16:12:43 EDT
David - this is similar to bug 597279 which you just sent a patch off for.
Comment 22 RHEL Product and Program Management 2010-06-04 11:58:42 EDT
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.
Comment 23 David Cantrell 2010-08-18 15:43:51 EDT
Deleted Technical Notes Contents.

Old Contents:
If unmodified kickstart files from Red Hat Enterprise Linux 5.4 are used to install Red Hat Enterprise Linux 5.5, anaconda may crash and complain that the directory required to save the log files does not exist.(BZ#568861)
Comment 26 Ruediger Landmann 2011-01-12 00:32:13 EST
    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:
Prior to Red Hat Enterprise Linux 5.5, the --log option in anaconda was 
not aware of whether %pre and %post scripts in  kickstart files were 
running in a chroot environment or not. Therefore, kickstart files had to
provide absolute paths to log files. Improvements to anaconda in Red Hat 
Enterprise Linux 5.5 made the --log option aware of chroot environments. 
Consequently, if unmodified kickstart files from Red Hat Enterprise Linux 
5.4 were used to install Red Hat Enterprise Linux 5.5, anaconda sometimes 
crashed and reported that the directory did not exist. The --log option 
is now further modified to accept either absolute or relative paths. The
presence of absolute paths does not prevent the use of kickstart files 
created for earlier versions of Red Hat Enterprise Linux 5.
Comment 28 errata-xmlrpc 2011-01-13 16:54:28 EST
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/RHBA-2011-0030.html

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