BusyBox Bug and Patch Tracking
BusyBox
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000548 [udhcp] minor N/A 11-16-05 15:28 02-12-08 13:00
Reporter akvadrako View Status public  
Assigned To
Priority normal Resolution no change required  
Status closed  
Summary 0000548: Fix a couple issues with sample simple udhcp script
Description There are some problems with the current simple udhcp sample script.

1. /etc/resolv.conf is deleted, then created. This doesn't work if it's a symlink because it's on a read-only filesystem. It should just to overwritten.

2. When eth0 is up, and has a default gateway, then eth1 comes up with udhcp, it shouldn't create a seconds default gateway. I don't think having a second default gateway is ever useful. Either delete the old one or suppress the new one. I opted for the second choice.

3. Normally, udhcp is run as a daemon. Therefor the output should go to syslog. So pipe the output of the script to logger. Better would be to modify udhcp to cature this output so as not to depend upon logger.

Additional Information #!/bin/sh

# udhcpc script edited by Tim Riker <Tim@Rikers.org> and Devin Bayer

[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1

{ # redirect to logger

RESOLV_CONF="/etc/resolv.conf"
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"

case "$1" in
    deconfig)
        /sbin/ifconfig $interface 0.0.0.0
        ;;

    renew|bound)
        /sbin/ifconfig $interface $ip $BROADCAST $NETMASK

        if [ -n "$router" ] ; then
            echo "deleting routers for interface $interface"
            while route -n del default gw 0.0.0.0 dev $interface 2> /dev/null; do
                true
            done

            if route -n | egrep "^0.0.0.0"; then
                echo "default route already in place"
            else
                echo "adding default router $router"
                route add default gw $router dev $interface
            fi
        fi

        if (! grep -q -v DISABLE_DHCP $RESOLV_CONF) && echo -n > $RESOLV_CONF; then
            [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
            for i in $dns ; do
                echo adding dns $i
                echo nameserver $i >> $RESOLV_CONF
            done
        fi
        ;;
esac
} 2>&1 | ( logger -s -p daemon.info -t uhdcp || cat )

exit 0
Attached Files

- Relationships

- Notes
(0004294)
vda
02-12-08 12:59

1. /etc/resolv.conf is deleted, then created. This doesn't work if it's a symlink because it's on a read-only filesystem. It should just to overwritten.

... and if two udhcp's will try to do it at once, even worse things could happen if you overwrite the file... like intermingled old and new file!...

2. When eth0 is up, and has a default gateway, then eth1 comes up with udhcp, it shouldn't create a seconds default gateway. I don't think having a second default gateway is ever useful. Either delete the old one or suppress the new one. I opted for the second choice.

... and there is no sufficient info for the script to know what is the *right* thing to do. It is simply cannot be decided at this point!...

3. Normally, udhcp is run as a daemon. Therefor the output should go to syslog. So pipe the output of the script to logger. Better would be to modify udhcp to cature this output so as not to depend upon logger.

...in depends on user. I never run udhcpc as daemon...
 
(0004304)
vda
02-12-08 13:00

Sorry, but these changes don't seem to be unquestionable improvements
 

- Issue History
Date Modified Username Field Change
11-16-05 15:29 akvadrako New Issue
04-27-06 01:31 veerasena_b Issue Monitored: veerasena_b
01-09-07 05:13 stephaneC Issue Monitored: stephaneC
02-12-08 12:59 vda Note Added: 0004294
02-12-08 13:00 vda Status new => closed
02-12-08 13:00 vda Note Added: 0004304
02-12-08 13:00 vda Resolution open => no change required


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker