Bug 139781 - Command "service netdump start" fails if file /h exists
Command "service netdump start" fails if file /h exists
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: netdump (Show other bugs)
4.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Dave Anderson
David Lawrence
:
Depends On:
Blocks: 140583
  Show dependency treegraph
 
Reported: 2004-11-17 19:00 EST by Hal Prince
Modified: 2007-11-30 17:07 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-01-17 16:43:46 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Hal Prince 2004-11-17 19:00:38 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.5)
Gecko/20031222

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):
netdump-0.7.0-1

How reproducible:
Always

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

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 09:20:22 EST
Jeff found it:

--- netdump-0.7.0/netdump.init.orig     2004-11-18 09:18:37.726245768
-0500
+++ netdump-0.7.0/netdump.init  2004-11-18 09:18:44.497216424 -0500
@@ -86,7 +86,7 @@ print_address_info ()
     IFS=$'\n'
     for line in $arp_output; do
         IFS=$oldIFS
-        set - foo $line
+        set -f - foo $line
         shift
         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 08:19:39 EST
That's the plan, yes.
Comment 8 Tim Burke 2004-11-22 19:50:59 EST
Setting state to MODIFIED.
Comment 9 Jay Turner 2004-11-23 09:05:48 EST
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 09:43:23 EST
Jeff, 

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

# ls /h
/h
# rpm -qa | grep 'netdump-0'
netdump-0.7.0-1
# 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
Preparing...               
########################################### [100%]
   1:netdump               
########################################### [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 09:48:18 EST
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 10:16:21 EST
Jay,

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 11:54:19 EST
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 11:56:12 EST
Created attachment 107312 [details]
netdump output
Comment 16 Hal Prince 2004-11-23 12:15:37 EST
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 - $@
        shift
        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
report.
Rather than preventing expansion, you might also consider
stripping [] from the arp -a output (with tr, say).
Comment 18 Dave Anderson 2004-11-23 15:24:15 EST
Created attachment 107334 [details]
/etc/init.d/netdump which replaces "set" with "read"
Comment 19 Dave Anderson 2004-11-23 15:25:46 EST
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 16:56:00 EST
The attached version will not suffice; testing has shown it can
fail when the address cannot be resolved. 
Comment 21 Jeffrey Moyer 2004-11-23 22:43:40 EST
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
happening:

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

    arp_output="$(LC_ALL=C arp -a | grep -v incomplete)"
    oldIFS=$IFS
    IFS=$'\n'
    for line in $arp_output; do
	IFS=$oldIFS
	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:
    [ether]
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
expansion.

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;
do

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 03:36:20 EST
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 11:03:44 EST
Patch applied to RHEL4 version 0.7.3-2
Comment 24 Jay Turner 2004-11-25 04:14:44 EST
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.