/etc/init.d/ntop fails to detect missing network interface

Bug #231024 reported by Ralph Corderoy
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
ntop (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: ntop

Ubuntu 8.04, ntop 3:3.2-10.1.

/etc/init.d/ntop has check_interfaces() which includes

    { echo $INTERFACES | awk -F , '{ for(i=1;i<=NF;i++) print $i }' |
    while read iface ; do
        if ! ifconfig "$iface" | grep -w UP >/dev/null; then
            echo "ERR: interface $iface is DOWN..."
            return 1
        fi
    done
    return 0
    }
    return $?

It's called thus.

    echo -n "Starting $DESC: "
    if ! sanity_check || ! check_log_dir || ! check_interfaces; then
        echo " will not start $DESC!"
        exit 1
    fi
    start-stop-daemon --start ...

Running the script with `bash -x' shows it isn't working as intended.

    + ifconfig eth0
    + grep -w UP
    eth0: error fetching interface information: Device not found
    + echo 'ERR: interface eth0 is DOWN...'
    ERR: interface eth0 is DOWN...
    + return 1
    + return 0
    + start-stop-daemon --start --quiet --name ntop --exec /usr/sbin/ntop -- -d -L -u ntop -P /var/lib/ntop --skip-version-check -a /var/log/ntop/access.log -i eth0 -p /etc/ntop/protocol.list -O /var/log/ntop

There's a `return 1' followed by a `return 0' so the error is getting
cleared with the result that the start-stop-daemon gets to try and start
the ill-configured daemon. It's probably due to using return inside an
if-statement inside a while-statement and bash subshells.

Revision history for this message
alej0 (alej0varas) wrote :

    "eth0: error fetching interface information: Device not found"

This error is from ifconfig not from ntop, the problem is that eth0 doesn't exist.

You can change the interface ntop works for in /var/lib/ntop/init.cfg

Revision history for this message
Ralph Corderoy (ralph-inputplus) wrote : Re: [Bug 231024] Re: /etc/init.d/ntop fails to detect missing network interface

Hi alej0, I think you've misunderstood. I'm aware that the error comes
from ifconfig(8) and that ifconfig is correct in giving it. But
/etc/init.d/ntop then proceeds to start-stop-daemon anyway, even though
its code attempts to avoid this precisely because ifconfig didn't say
`UP'. The code isn't behaving as the author intended and that's the
bug. The output from `bash -x' I gave shows this.

Revision history for this message
alej0 (alej0varas) wrote :

Sorry for the misunderstood. Now I got it, here is a patch for /etc/init.d/ntop.

Revision history for this message
Shirish Agarwal (shirishag75) wrote :

alej0,
    It would be nice if you could/would forward the patch upstream as well (for consideration) .

I also ran into this bug and had to use your work-around. ntop should be intelligent to know which interfaces is actually up and doing stuff.

Revision history for this message
Ludovico Cavedon (cavedon) wrote :

The next upload of ntop will fix this issue.
Thank for reporting the issue.

Changed in ntop (Ubuntu):
status: New → Fix Committed
Revision history for this message
Ralph Corderoy (ralph-inputplus) wrote :

Is there an easy way to see the fixed /etc/init.d/ntop or its source?

Revision history for this message
Ludovico Cavedon (cavedon) wrote :

On 01/25/2011 07:14 AM, Ralph Corderoy wrote:
> Is there an easy way to see the fixed /etc/init.d/ntop or its source?

Here:
http://git.debian.org/?p=collab-maint/ntop.git;a=blob;f=debian/ntop.init

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ntop - 3:4.0.3+dfsg1-2

---------------
ntop (3:4.0.3+dfsg1-2) unstable; urgency=low

  [ Ludovico Cavedon ]
  * Rename maintainer scripts including the package name.
  * Remove misplaced ru.po file.
  * Add Vcs-* headers.
  * Do not call netstat, but read interface list from /proc (Closes: #607637).
  * Use "set -e" in maintainer scripts (see lintian warning
    maintainer-script-without-set-e).
  * Fix bug in check_interfaces() config function.
  * ntop.default: avoid prerm failure if package has never been fully
    configured.
  * Prevent config script failure if password is not asked (Closes: #607580).
  * Cleanup postrm script, thanks to J.M.Roth (Closes: #568626):
    - do not delete user (might be shared)
    - no need to remove /etc/ntop
    - wrap db_purge in a debconf availability check
    - re-indent
  * Add hostname-in-man-description.patch by A. Costa in order to add
    hostname:port in the description section of the man page
    (Closes: #466506).
  * Remove init.cfg from source package, as it is generated by postinst.
  * Handle interface "none", merged patch from Jason Healy (Closes: #520319).
  * Add dependency on net-tools, needed by the init script.
  * Make sure /var/log/ntop is not world readable and set group to adm. Thanks
    to J.M.Roth (Closes: #568641).
  * Set random password admin password if no password have ever been set
    and it is not possible to ask the user (LP: #355127).
  * Suggest geoip-database-contrib and add symlinks to its files.
    Explained in README.Debian.
  * Fix permissions in /var/lib/ntop (LP: #138682). Set sticky bit on
    /var/lib/ntop, so ntop user cannot change init.cfg, but can create
    subdirectories.
  * Disable DNS resolution as it makes ntop unstable.
  * Fix detection of not-active interfaces in ntop.init (LP: #231024).
  * Update po files.

  [ Jordan Metzmeier ]
  * Set password in postinst instead of config (Closes: #609070)
  * Add prompt to reset password if it is already set.
  * Update debconf template thanks to reviews by Christian Perrier and
    Justin B Rye.

  [ Daniel Baumann ]
  * Correct chown calls in ntop.postinst to not fail upon initial installation
    when the respective files are not yet present on the system.
 -- Ludovico Cavedon <email address hidden> Tue, 25 Jan 2011 23:39:56 -0800

Changed in ntop (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.