Bug 811363

Summary: lua rpm scripts do not properly restore path after running
Product: Red Hat Enterprise Linux 6 Reporter: Chris Seawood <cls>
Component: rpmAssignee: Panu Matilainen <pmatilai>
Status: CLOSED DUPLICATE QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 6.2CC: pkis
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-07-02 07:50:04 UTC Type: Bug
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
testbar.spec
none
testfoo.spec
none
fix chroot handling for lua scripts
none
lua script chroot v1.1 none

Description Chris Seawood 2012-04-10 19:51:17 UTC
In EL6.2, there are a handful of rpms that use lua for rpm %post/%postun scripts.  When these rpms are upgraded manually using 'rpm -Uv', rpm complains that it cannot find the rest of the rpms after processing the first rpm that uses a lua script.  Using yum works but it's not always an option.

I've attached 2 proof of concept rpm spec files which will show the problem. To reproduce, build the rpms and run: 
     cd /path/to/rpms && rpm -Uvh test{foo,bar}*.rpm

The output looks like this:

[root@optimus ~]# ls
anaconda-ks.cfg  install.log.syslog  testbar-1.0-1.sc00.x86_64.rpm
install.log      ks-post.log         testfoo-1.0-1.sc00.x86_64.rpm
[root@optimus ~]# rpm -Uvh test*.rpm
Preparing...                ########################################### [100%]
   1:testfoo                ########################################### [ 50%]
Tue 10 Apr 2012 11:52:46 AM PDT
error: open of testbar-1.0-1.sc00.x86_64.rpm failed: No such file or directory


runLuaScript() doesn't properly reset the current working directory after running the lua script.  The attached patch fixes the problem for me.

[root@optimus ~]# rpm -e testfoo
[root@optimus ~]# rpm -Uvh test*.rpm
Preparing...                ########################################### [100%]
   1:testfoo                ########################################### [ 50%]
Tue 10 Apr 2012 12:33:55 PM PDT
   2:testbar                ########################################### [100%]

Comment 1 Chris Seawood 2012-04-10 19:51:52 UTC
Created attachment 576575 [details]
testbar.spec

Comment 2 Chris Seawood 2012-04-10 19:52:18 UTC
Created attachment 576576 [details]
testfoo.spec

Comment 3 Chris Seawood 2012-04-10 19:53:07 UTC
Created attachment 576577 [details]
fix chroot handling for lua scripts

Comment 5 Chris Seawood 2012-04-13 03:53:39 UTC
Created attachment 577219 [details]
lua script chroot v1.1

The previous patch broke mock.  Apparently, the result of rpmtsCurrDir() cannot be trusted and I had to use getcwd() instead.

Comment 6 Panu Matilainen 2012-04-16 10:25:51 UTC
This is a dupe of bug 746190 (which is a closed bug, for whatever reason). In any case, its being addressed.

Comment 7 RHEL Program Management 2012-05-03 05:17:18 UTC
Since RHEL 6.3 External Beta has begun, and this bug remains
unresolved, it has been rejected as it is not proposed as
exception or blocker.

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 8 Panu Matilainen 2012-07-02 07:50:04 UTC
This has been fixed as of http://rhn.redhat.com/errata/RHBA-2012-0909.html

*** This bug has been marked as a duplicate of bug 746190 ***

Comment 9 Panu Matilainen 2015-01-19 09:05:53 UTC
Clearing up leftover review flag