Bug 830853 - Embedded lua has strange command line parameters (arg array) indexing
Embedded lua has strange command line parameters (arg array) indexing
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: rpm (Show other bugs)
17
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Fedora Packaging Toolset Team
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-11 10:15 EDT by Jan Pazdziora
Modified: 2013-05-21 07:15 EDT (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-05-21 04:13:19 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jan Pazdziora 2012-06-11 10:15:51 EDT
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 03:14:18 EDT
print(arg[0])
print(arg[1])
print(arg[2])
->
nil
<lua>
1

Don't ask me why...
Comment 2 Jan Pazdziora 2012-06-13 04:02:31 EDT
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 05:24:46 EDT
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 05:35:06 EDT
(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 06:40:37 EDT
(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 06:50:11 EDT
(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 11:49:52 EST
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 13:09:53 EST
(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 04:13:19 EDT
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 07:15:23 EDT
I think the documentation amendment is just fine. Thank you!

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