Bug 102199 - syntax error in ifup when no default route exists
syntax error in ifup when no default route exists
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: initscripts (Show other bugs)
9
i686 Linux
low Severity medium
: ---
: ---
Assigned To: Bill Nottingham
Brock Organ
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-08-12 10:19 EDT by Jon Beck
Modified: 2014-03-16 22:38 EDT (History)
2 users (show)

See Also:
Fixed In Version: 7.29-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-08-12 11:45:17 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jon Beck 2003-08-12 10:19:22 EDT
Description of problem: When there is no default route as reported by ip, the
following error message appears in the log files:

Aug 12 08:08:10 vh216203 ifup: ./ifup: line 268: [: : integer expression expected

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

initscripts-7.14-1

How reproducible:
Have no default route and give the command:

service network restart

Steps to Reproduce:
1.
2.
3.
    
Actual results:


Expected results:


Additional info:

The problem is that the awk command on line 267 produces no output if there is
no default route, because nlines is not initialized.  The following diff shows a
script that I think gives the results you desire:

$ diff /sbin/ifup /tmp/ifup-fixed
267,268c267,268
<                   awk '{ nlines++ } END { print nlines }'`
<     if [ -n "$NUMDEFROUTES" -a "$NUMDEFROUTES" -gt 1 ]; then
---
>                   awk 'BEGIN { nlines = 0 } { nlines++ } END { print nlines }'`
>     if [ "$NUMDEFROUTES" -gt 1 ]; then

This change guarantees that $NUMDEFROUTES will have a numeric non-negative format.
Comment 1 Bill Nottingham 2003-08-12 11:45:17 EDT
Already fixed in 7.29-1.
Comment 2 Vladimir Kondratiev 2003-11-13 04:01:33 EST
Fix should get lost. In initscripts 7.42-1 (Fedora core 1),
corresponded strings reads as (/sbin/ifup:307):

    NUMDEFROUTES=`ip -o route | \
                  awk '/^default/ { nlines++ } END { print nlines }'`

so "BEGIN { nlines=0 }" missed.
 I have no power to reopen this bug, but logically, it should be reopened.
Comment 3 Bill Nottingham 2003-11-13 11:23:36 EST
It's fixed differently, the if [...] clause was changed.

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