Bug 459823 - `` expansion in /etc/profile.d *.sh files do not provide correct number of parameters to '[' builtin
`` expansion in /etc/profile.d *.sh files do not provide correct number of pa...
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: vim (Show other bugs)
All Linux
medium Severity low
: rc
: ---
Assigned To: Karsten Hopp
Depends On:
  Show dependency treegraph
Reported: 2008-08-22 13:43 EDT by pr-rhat
Modified: 2013-04-12 15:51 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2009-06-22 13:27:38 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2009:1117 normal SHIPPED_LIVE vim bug fix update 2009-06-22 13:27:19 EDT

  None (edit)
Description pr-rhat 2008-08-22 13:43:18 EDT
Description of problem:

/etc/profile.d/*sh files for krb5-devel, krb5-workstation, vim-enhanced, and probably other packages make the incorrect assumption that `id -u` always returns something other than ''

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


How reproducible:

See bug 448014 for one set of events causing the bug to be reproduced.

Steps to Reproduce:
Actual results:

.sh file errors out with 
'-bash: [: -le: unary operator expected'

Expected results:

No output

Additional info:

The root cause of this bug are incorrectly written .sh files.

They use the construct 
[ `/usr/bin/id -u` = 0 ] 
[ `/usr/bin/id -u` -le 100 ]

The proper construct to guarantee enough parameters to the '[' shell builtin is
[ "$(/usr/bin/id -u)" = 0]
[ "$(/usr/bin/id -u" -le 100 ]

Chris Dukes
Comment 3 Karsten Hopp 2009-05-14 08:32:37 EDT
This construct won't work either as p.e.  '-le' doesn't accept an empty string
as an integer.
The correct fix is to check the value of id -u before using it. Please note that
I'm not setting the alias for security reasons when id -u returns nothing.

  tmpid=$(/usr/bin/id -u)
  [ "$tmpid" = "" ] && tmpid=0
  [ $tmpid -le 100 ] && return
Comment 7 errata-xmlrpc 2009-06-22 13:27:38 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.


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