Bug 139781 - Command "service netdump start" fails if file /h exists
Summary: Command "service netdump start" fails if file /h exists
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: netdump
Version: 4.0
Hardware: All
OS: Linux
Target Milestone: ---
: ---
Assignee: Dave Anderson
QA Contact: David Lawrence
Depends On:
Blocks: 140583
TreeView+ depends on / blocked
Reported: 2004-11-18 00:00 UTC by Hal Prince
Modified: 2007-11-30 22:07 UTC (History)
5 users (show)

Clone Of:
Last Closed: 2005-01-17 21:43:46 UTC

Attachments (Terms of Use)
netdump output (2.99 KB, text/plain)
2004-11-23 16:56 UTC, Jay Turner
no flags Details
/etc/init.d/netdump which replaces "set" with "read" (8.88 KB, text/plain)
2004-11-23 20:24 UTC, Dave Anderson
no flags Details
Address the issue with netdump not starting if /h exists. (2.84 KB, patch)
2004-11-24 03:43 UTC, Jeff Moyer
no flags Details | Diff

Description Hal Prince 2004-11-18 00:00:38 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.5)

Description of problem:
If your root directory has a file named /h,
then the command "service netdump start" fails.  The reason
is that the netdump startup script /etc/init.d/netdump 
performs unintentional pathname expansion on the name of
the interface type when it is "[ether]". 


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

How reproducible:

Steps to Reproduce:
1.touch /h
2.service netdump start

Actual Results:  # service netdump start
netdump: eth0 must be an ethernet interface
netdump eth0 configuration

Expected Results:  command success

Additional info:

Comment 2 Dave Anderson 2004-11-18 14:20:22 UTC
Jeff found it:

--- netdump-0.7.0/netdump.init.orig     2004-11-18 09:18:37.726245768
+++ netdump-0.7.0/netdump.init  2004-11-18 09:18:44.497216424 -0500
@@ -86,7 +86,7 @@ print_address_info ()
     for line in $arp_output; do
-        set - foo $line
+        set -f - foo $line
         if [ "$2" = "($host)" ] || expr "$1" : "$host" &>/dev/null; then
             echo HOSTNAME=$1 IPADDR=$2 AT=$3 MAC=$4 \

Comment 4 Dave Anderson 2004-11-19 13:19:39 UTC
That's the plan, yes.

Comment 8 Tim Burke 2004-11-23 00:50:59 UTC
Setting state to MODIFIED.

Comment 9 Jay Turner 2004-11-23 14:05:48 UTC
0.7.1-2 *doesn't* fix this issue, although it appears that it should.  So, not
really sure what's going on.  Did your testing show this to work?

Comment 11 Dave Anderson 2004-11-23 14:43:23 UTC

Jeff, here's a test on ewouldblock.lab:

# ls /h
# rpm -qa | grep 'netdump-0'
# service netdump start
netdump: eth0 must be an ethernet interface
netdump eth0 configuration
# rpm -Uvh /usr/tmp/netdump-0.7.1-2.i386.rpm
warning: /usr/tmp/netdump-0.7.1-2.i386.rpm: V3 DSA signature: NOKEY,
key ID 897da07a
########################################### [100%]
########################################### [100%]
# service netdump start
netdump: eth0 must be an ethernet interface
netdump eth0 configuration                                 [FAILED]
# grep 'set ' /etc/init.d/netdump
        set -f - foo $line

I know we tested this the other day -- any ideas?

Comment 12 Dave Anderson 2004-11-23 14:48:18 UTC
Note that ewouldblock.lab is running RHEL4.

I cannot reproduce the problem on my RHEL3 machine.
It seems to works with, or without, the -f now, which I've
got commented out in my netdump script:

$ touch /h
$ service netdump start
initializing netdump                                       [  OK  ]
$ grep 'set ' /etc/init.d/netdump
#       set -f - foo $line
        set - foo $line

Comment 13 Dave Anderson 2004-11-23 15:16:21 UTC

What version of the initscripts is running on your test box?

With the latest (initscripts-7.93.10.EL-1) installed on an x86_64,
the netdump fix works.

Comment 14 Jay Turner 2004-11-23 16:54:19 UTC
initscripts-7.90-1 is what I was seeing it with.  Even updating to
initscripts-7.93.10.EL-1, I'm still seeing a failure.  Attached is exploded
output from 'service netdump start' which shows that the 'set' line is getting
"e" for the Type, as opposed to "[ether]"

Comment 15 Jay Turner 2004-11-23 16:56:12 UTC
Created attachment 107312 [details]
netdump output

Comment 16 Hal Prince 2004-11-23 17:15:37 UTC
In diagnosing this before I submitted the bug, I found that
the expansion could happen in more than one place.
My eventual workaround was
        set -f - foo "$line"
        set -f - $@
        if [ "$2" = "($fhip)" ] || expr "$1" : "$host" &>/dev/null; then
            echo HOSTNAME=$host IPADDR=$hostip AT=$3 MAC=$4 \
                 TYPE="'""$5""'" ON=$6 IFACE=$7
which was so bizarre that I didn't submit it as part of the
Rather than preventing expansion, you might also consider
stripping [] from the arp -a output (with tr, say).

Comment 18 Dave Anderson 2004-11-23 20:24:15 UTC
Created attachment 107334 [details]
/etc/init.d/netdump which replaces "set" with "read"

Comment 19 Dave Anderson 2004-11-23 20:25:46 UTC
Attached version of /etc/init.d/netdump (a.k.a netdump.init)
which replaces "set" usage with "read".

Comment 20 Dave Anderson 2004-11-23 21:56:00 UTC
The attached version will not suffice; testing has shown it can
fail when the address cannot be resolved. 

Comment 21 Jeff Moyer 2004-11-24 03:43:40 UTC
Created attachment 107374 [details]
Address the issue with netdump not starting if /h exists.

This patch fixes the problem in my environment, tested under both RHEL 3 and
RHEL 4.  I've sent it off to Dave for review.  Here is a run-down of what was

The init script walks through the arp table entries like so:

    arp_output="$(LC_ALL=C arp -a | grep -v incomplete)"
    for line in $arp_output; do
	set -f - foo $line

The contents of $line are broken out into $1 $2 $3 ... $n by the set command. 
However, part of $line is the following string:
This is treated as a glob match.  Since the service script will cd into the /
directory before executing the script, the above glob will match files or
directories with names of 'e' 't' 'h' 'e' or 'r'.  Now, because of the way the
code is structured, there is no way to tell bash to not do this.  At least, I
couldn't find one.  I thought -f should have kept it from doing filename

So, in order to fix the problem, I've rearranged that bit of code.  It now
looks as follows:
    arp_output="$(LC_ALL=C arp -a | grep -v incomplete)"
    echo "$arp_output" | ( while read hostname ipaddr at mac iftype on iface;

Here, read takes care of assigning individual parts of each line in the
arp_output to the respective variables.  I also like this a bit better because
it gives the variables names, as opposed to $1 - $n (makes things more
readable).  The bug with my initial stab at this was simply that I left in the
$IFS munging.  Taking that out makes things better (it essentially changed the
field separator so that the first time through the loop, the entire line would
be assigned to the first variable).

Comment 22 Jay Turner 2004-11-24 08:36:20 UTC
The patch in comment 21 does indeed fix things on my system, so let's get that
integrated into a package and built.  Thanks!

Comment 23 Dave Anderson 2004-11-24 16:03:44 UTC
Patch applied to RHEL4 version 0.7.3-2

Comment 24 Jay Turner 2004-11-25 09:14:44 UTC
netdump-0.7.3-2 does indeed resolve these issues that I was seeing.  That
version of the package is in 4E, but hasn't been built into a tree yet, so
chunking this bug into ON_QA.

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