Bug 455276 - /usr/lib/rpm/perl.req mishandles quoted strings and bareword syntax
Summary: /usr/lib/rpm/perl.req mishandles quoted strings and bareword syntax
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: 11
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Panu Matilainen
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-07-14 16:25 UTC by Joe Krahn
Modified: 2010-06-28 10:41 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-06-28 10:41:08 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
A modfied 'perl.req' script to illustrate some possible design changes. (5.77 KB, text/plain)
2008-07-14 22:21 UTC, Joe Krahn
no flags Details

Description Joe Krahn 2008-07-14 16:25:28 UTC
Description of problem:
/usr/lib/rpm/perl.req simply ignores quotes and treats all references as if they
use the bareword syntax. The script converts all '/' to '::', which is only
valid for quoted strings ending in ".pm". The script needs to consider the
difference between module references and file references. For example, the first
two referneces below are equivalent, but the third one is not:

require Foo::Bar;
require "Foo/Bar.pm";
require "Foo::Bar";

See `perldoc -f require' where it says:
If EXPR is a bareword, the require assumes a ".pm" extension and replaces "::"
with "/" in the filename for you, to make it easy to load standard modules.

The problem now is that simply non-module files with a leading directory are
misinterpreted. The most common example is ".ph" references like "sys/fcntl.ph",
which perl.req avoids by simply excluding them, rather than dealing with the
underlying design flaw.

It would be better if the dependency syntax also distinguished filename and
module references. For example, file references could include quotes like
`perl("hostname.pl")', or a prefix like `perl(file:hostname.pl)'. Maybe it's too
late to do something like that, but the dependency checkers at least need to be
smart enough to know that filename and module references are different.

In the case of file references, it would be nice to automatically exclude
requirements when the matching filename exists in the same directory as the
script, to avoid generating requirements when a script is simply loading a local
data or configuration file.

Version-Release number of selected component (if applicable):
rpm-build-4.4.2.2-7.fc8

How reproducible:
Always.

Steps to Reproduce:
1. Create a Perl source containing `require "data/config.pl";'
2. Run /usr/lib/rpm/perl.req on that file.
3.
  
Actual results:
perl(data::config.pl)

Expected results:
perl(data/config.pl)

Additional info:
I would include something like the following in the perl.req script. First,
change the search regex to include the quotes:

   ([\'\"]?[^\;\ \'\"\t]*[\'\"]?)[\t\;\ ]

Then, only convert to bareword module syntax if it is a module reference,
otherwise just remove quotes.

if ($module =~ m/(['"])(.*)\.pm\1/) {
  $module = $2;
  $module =~ s{/}{::}g;
} else {
  $module =~ s/^["']|["']$//g;
  # $module =~ s/^[']|[']$/"/g; # Or, keep file-references distinct
}

Comment 1 Joe Krahn 2008-07-14 22:19:32 UTC
I am attaching an example of a modified perl.req which keeps bareword and
filename references distinct. The regexp is more restrictive, and avoids some of
the extra false-positive checks. It also allows for the leading 'v' in perl
version references.

The regexp could include a more restrictive pattern for what is allowed to come
after the module or file name, to avoid false matches to plain text sentences
containing 'use'. For example, maybe only allow semicolon, parenthesis, or qw().

Comment 2 Joe Krahn 2008-07-14 22:21:23 UTC
Created attachment 311783 [details]
A modfied 'perl.req' script to illustrate some possible design changes.

Comment 3 Bug Zapper 2008-11-26 11:00:08 UTC
This message is a reminder that Fedora 8 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 8.  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 '8'.

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 8'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 8 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 please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

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 4 Bug Zapper 2009-06-09 09:38:30 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 11 development cycle.
Changing version to '11'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 5 Bug Zapper 2010-04-27 12:08:42 UTC
This message is a reminder that Fedora 11 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 11.  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 '11'.

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 11'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 11 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 please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

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 6 Bug Zapper 2010-06-28 10:41:08 UTC
Fedora 11 changed to end-of-life (EOL) status on 2010-06-25. Fedora 11 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.


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