Bug 459823 - `` expansion in /etc/profile.d *.sh files do not provide correct number of parameters to '[' builtin
Summary: `` expansion in /etc/profile.d *.sh files do not provide correct number of pa...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: vim
Version: 5.4
Hardware: All
OS: Linux
medium
low
Target Milestone: rc
: ---
Assignee: Karsten Hopp
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-08-22 17:43 UTC by pr-rhat
Modified: 2018-10-16 17:21 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-06-22 17:27:38 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2009:1117 0 normal SHIPPED_LIVE vim bug fix update 2009-06-22 17:27:19 UTC

Description pr-rhat 2008-08-22 17:43:18 UTC
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):

krb5-devel-1.6.1-25.el5
krb5-workstation-1.6.1-25.el5
vim-enhanced-7.0.109-3.el5.3


How reproducible:

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

Steps to Reproduce:
1.
2.
3.
  
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 ] 
and
[ `/usr/bin/id -u` -le 100 ]

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

Thanks,
Chris Dukes

Comment 3 Karsten Hopp 2009-05-14 12:32:37 UTC
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 17:27:38 UTC
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.

http://rhn.redhat.com/errata/RHBA-2009-1117.html


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