Bug 102199 - syntax error in ifup when no default route exists
Summary: syntax error in ifup when no default route exists
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: initscripts
Version: 9
Hardware: i686
OS: Linux
low
medium
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-08-12 14:19 UTC by Jon Beck
Modified: 2014-03-17 02:38 UTC (History)
2 users (show)

Fixed In Version: 7.29-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2003-08-12 15:45:17 UTC
Embargoed:


Attachments (Terms of Use)

Description Jon Beck 2003-08-12 14:19:22 UTC
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 15:45:17 UTC
Already fixed in 7.29-1.

Comment 2 Vladimir Kondratiev 2003-11-13 09:01:33 UTC
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 16:23:36 UTC
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.