Bug 830853

Summary: Embedded lua has strange command line parameters (arg array) indexing
Product: [Fedora] Fedora Reporter: Jan Pazdziora <jpazdziora>
Component: rpmAssignee: Fedora Packaging Toolset Team <packaging-team>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 17CC: ffesti, jnovy, jpazdziora, maxamillion, packaging-team, pknirsch, pmatilai, rrakus
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-05-21 08:13:19 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:

Description Jan Pazdziora 2012-06-11 14:15:51 UTC
Description of problem:

The lua-written postuninstall script of bash does

if arg[2] == "0"

where the traditional /bin/sh-based scripts (including the bash postuninstall in RHEL 6) do

if [ "$1" = 0 ]; then

The does not seem right.

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

# rpm -q bash
bash-4.2.28-1.fc16.x86_64

How reproducible:

Deterministic.

Steps to Reproduce:
1. Do rpm -q --scripts bash
  
Actual results:

if arg[2] == "0"

in output.

Expected results:

if arg[1] == "0"

in output.

Additional info:

I also believe that due to this bug, uninstalling bash altogether will not remove the entries from /etc/shells, so that can be your second reproducer, even if I did not actually try to remove bash.

Comment 1 Roman Rakus 2012-06-13 07:14:18 UTC
print(arg[0])
print(arg[1])
print(arg[2])
->
nil
<lua>
1

Don't ask me why...

Comment 2 Jan Pazdziora 2012-06-13 08:02:31 UTC
Reopening and moving to rpm component. On normal command line, lua behaves as expected and documented -- arg[0] is the command name and parameters start from arg[1]:

$ cat /tmp/klwer.lua 
#!/usr/bin/lua

print(arg[0])
print(arg[1])
print(arg[2])
$ lua /tmp/klwer.lua 1 3
/tmp/klwer.lua
1
3
$ /tmp/klwer.lua 1 3
/tmp/klwer.lua
1
3

The embedded interpret should do the same, while Roman's example in comment 1 suggests that it inserts an extra value to the array.

Comment 3 Panu Matilainen 2012-06-18 09:24:46 UTC
Yes, unfortunately the <lua> arguments are inconsistent with traditional scriptlet arguments. The problem is that "fixing" it would do little else than break all the packages written to work with the current argument style which has been the way it is for a long time for only a "cosmetic" gain.

Comment 4 Roman Rakus 2012-06-18 09:35:06 UTC
(In reply to comment #3)
> Yes, unfortunately the <lua> arguments are inconsistent with traditional
> scriptlet arguments. The problem is that "fixing" it would do little else
> than break all the packages written to work with the current argument style
> which has been the way it is for a long time for only a "cosmetic" gain.

It is not only cosmetic. Now it is inconsistent - embedded lua and standalone lua. You can fix it in rawhide, make an announce on devel list, ... And of course it is possible to make a list of packages which use lua scripting.

Comment 5 Panu Matilainen 2012-06-18 10:40:37 UTC
(In reply to comment #4)
> You can fix it in rawhide, make an announce on devel list,
> ... And of course it is possible to make a list of packages which use lua
> scripting.

If it were that trivial it would've been fixed already. Rpm needs to remain backwards-compatible with packages built 10+ years ago, including those outside the fedora ecosystem, and the scriptlet calling convention one (very) important part of that. On top of that, there are considerable forward-compatibility demands on rpm as well: anything in rawhide must be installable by whatever the builders are running, for the time being that would be rhel-6.

The only way to compatibly change the arguments would be something like introducing a new variant of <lua> (or additional compatibility tracking bit) where the arguments are "sane", add rpmlib() feature tracking for it, backport to rhel-6 etc etc. It's simply far more trouble than its worth, annoying as the inconsistency might be.

Comment 6 Jan Pazdziora 2012-06-18 10:50:11 UTC
(In reply to comment #5)
> 
> The only way to compatibly change the arguments would be something like
> introducing a new variant of <lua> (or additional compatibility tracking
> bit) where the arguments are "sane", add rpmlib() feature tracking for it,
> backport to rhel-6 etc etc. It's simply far more trouble than its worth,
> annoying as the inconsistency might be.

OKay. Can we at least have the inconsistency documented anywhere <lua> is mentioned?

Comment 7 Fedora End Of Life 2013-01-16 16:49:52 UTC
This message is a reminder that Fedora 16 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 16. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '16'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 16's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 16 is end of life. If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora, you are encouraged to click on 
"Clone This Bug" and open it against that version of Fedora.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 8 Jan Pazdziora 2013-01-16 18:09:53 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > 
> > The only way to compatibly change the arguments would be something like
> > introducing a new variant of <lua> (or additional compatibility tracking
> > bit) where the arguments are "sane", add rpmlib() feature tracking for it,
> > backport to rhel-6 etc etc. It's simply far more trouble than its worth,
> > annoying as the inconsistency might be.
> 
> OKay. Can we at least have the inconsistency documented anywhere <lua> is
> mentioned?

I mean, for example at http://www.rpm.org/wiki/PackagerDocs/RpmLua ? I know it's a wiki but it wants some login to edit and hopefully rpm maintainers should have one ...

Comment 9 Panu Matilainen 2013-05-21 08:13:19 UTC
The arg table and the off-by-one quirk is now documented in http://www.rpm.org/wiki/PackagerDocs/RpmLua. Other than that I'm afraid this is a WONTFIX due to the compatibility requirements.

Comment 10 Jan Pazdziora 2013-05-21 11:15:23 UTC
I think the documentation amendment is just fine. Thank you!