Bug 121993

Summary: rpm cannot handle filenames with square brackets in them
Product: Red Hat Enterprise Linux 3 Reporter: Ken Snider <ksnider>
Component: rpmAssignee: Jeff Johnson <jbj>
Status: CLOSED WONTFIX QA Contact: Mike McLean <mikem>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0CC: msw
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-05-04 16:19:29 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ken Snider 2004-04-29 16:28:14 UTC
Description of problem:
Passing a filename with square brackets in it to RPM will result in
RPM being unable to find the filem even though said characters are
valid in a filename.

Example:

[root@<server> ksnider]# rpm -ihv 'libusb-0[1].1.6-3.i386.rpm'
error: File not found by glob: libusb-0[1].1.6-3.i386.rpm

Version-Release number of selected component:
rpm-4.2.1-4.4

How reproducible:
Always

Steps to Reproduce:
1. Add square brackets to a filename (libusb-0[1].1.6-3.i386.rpm)
2. Ask RPM to perform an operation on it (-i and -U were tried)
3. Witness the 'File not found by glob' error message.

Comment 1 Jeremy Katz 2004-04-29 22:16:25 UTC
This isn't a bug in RPM.  bash is seeing the existence of the file and
doing globbing on the command line before passing the args to rpm.

Comment 2 Ken Snider 2004-04-29 22:32:39 UTC
*Really now*..

[root@<host> ksnider]# echo 'libusb-0[1].1.6-3.i386.rpm'
libusb-0[1].1.6-3.i386.rpm
[root@<host> ksnider]# less 'libusb-0[1].1.6-3.i386.rpm'
"libusb-0[1].1.6-3.i386.rpm" may be a binary file.  See it anyway?
[root@<host> ksnider]# grep usb 'libusb-0[1].1.6-3.i386.rpm'
Binary file libusb-0[1].1.6-3.i386.rpm matches
[root@<host> ksnider]# ls -l 'libusb-0[1].1.6-3.i386.rpm'
-rw-r--r--    1 root     root        11382 Apr 29 15:48
libusb-0[1].1.6-3.i386.rpm

Amazing how every other program can *perfectly interpret* what is
being passed to it as an argument, hm?

See, bash has this neat little feature called "Shell Grammar". This
grammar allows you to modify the arguments given to a file such that
the arguments aren't otherwise manipulated by the shell. The Oreilly
bash book can probably explain this is more detail, but I'll do you
the favour of including an excerpt from the man page:

"Enclosing  characters  in  single quotes preserves the literal value
of each character within the quotes.  A single quote may not occur
between single quotes, even when preceded by a backslash."

In other words, no. The shell is *not* seeing the existence of
anything and doing anything to it. That was the purpose of the single
quotes surrounding the text - to remove any expansion performed by the
shell.

No, I'm afraid this really is a bug in RPM. Sorry.

Comment 3 Jeff Johnson 2004-05-04 15:19:06 UTC
Putting square brackets in file names is asking for trouble.
Have fun!


Comment 4 Ken Snider 2004-05-04 15:38:12 UTC
*sigh*

You understand that this behavior is both part of the POSIX
specification, and REQUIRED for LSB compliance, yes?

Specifically Chapter 23 of LSB 1.3 indicates that "Utilities that
perform filename globbing (also known as Pattern Matching Notation)
shall do it as specified in the Single UNIX Specification".

Section 2.13 of said Specification (Pattern Matching Notation)
indicates that a single bracket character should only be treated as a
special character if unescaped.

This is an LSB-compliance-affecting BUG in RPM. More importantly, as
I've shown, RPM's behaviour is INCONSISTENT with other system
utilities which *do* follow POSIX/LSB specifications in handling files
of this type.

Comment 5 Jeff Johnson 2004-05-04 16:19:29 UTC
Yup.