This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours

Bug 460577

Summary: dhclient-script produces "integer expression expected"
Product: [Fedora] Fedora Reporter: Michal Jaegermann <michal>
Component: dhcpAssignee: David Cantrell <dcantrell>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: mmaslano, wwoods
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-09-16 20:23:38 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:

Description Michal Jaegermann 2008-08-28 15:09:10 EDT
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 15:41:31 EDT
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 05:25:58 EDT
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 13:20:48 EDT
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-16 20:23:38 EDT
Closing per comment #3.