Bug 460577 - dhclient-script produces "integer expression expected"
Summary: dhclient-script produces "integer expression expected"
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: dhcp
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: David Cantrell
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-08-28 19:09 UTC by Michal Jaegermann
Modified: 2008-09-17 00:23 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-09-17 00:23:38 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Michal Jaegermann 2008-08-28 19:09:10 UTC
Description of problem:

Every time when bringing an interface up one gets:

/sbin/dhclient-script: line 186: [: '': integer expression expected

Running that with 'bash -x' shows that the following happens:
....
+ add_default_gateway 192.168.2.254 ''\'''\'''
+ router=192.168.2.254
+ metric=
+ '[' 2 -gt 1 ']'
+ '[' ''\'''\''' -gt 0 ']'
/sbin/dhclient-script: line 186: [: '': integer expression expected
....

Why string '' is passed as an argument I really do not know
but if this something expected then something like that should
make that work:

--- /sbin/dhclient-script.orig  2008-08-24 19:31:58.000000000 -0600
+++ /sbin/dhclient-script       2008-08-28 12:40:14.000000000 -0600
@@ -182,10 +182,9 @@ is_router_reachable() {
 add_default_gateway() {
     router="${1}"
     metric=""
-
-    if [ $# -gt 1 ] && [ ${2} -gt 0 ]; then
-        metric="metric ${2}"
-    fi
+    local lmetric
+    eval "lmetric=${2}"
+    [ -n "$lmetric" ] && metric=$lmetric

     if is_router_reachable ${router} ; then
         ip route replace default via ${router} dev ${interface} ${metric}


Currently there are two arguments but the second one
does not need to be numeric.

Version-Release number of selected component (if applicable):
dhcp-4.0.0-22.fc10

How reproducible:
always

Comment 1 Michal Jaegermann 2008-08-28 19:41:31 UTC
Opps!  The above patch is not correct if the second argument is
really a number.  The last replacement line should read:

   [ -n "$lmetric" ] && metric="metric $lmetric"

Does 'metric' variable really needs to be global?

Comment 2 David Cantrell 2008-09-04 09:25:58 UTC
Is this problem occurring with dhcp-4.0.0-23.fc10?  I had changed the initial setting of metric to:

metric="${METRIC:-}"

Originally it was:

metric="${METRIC:-''}"

So metric was getting the value of "''" and interfering with the integer test in add_default_gateway().

Comment 3 Michal Jaegermann 2008-09-05 17:20:48 UTC
dhcp-4.0.0-23.fc10 does not have that issue.  Too many quotes
in the original. :-)  Loosing external doubles in 'metric'
initialization would have the same effects.  Thanks.

Comment 4 David Cantrell 2008-09-17 00:23:38 UTC
Closing per comment #3.


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