Search
j0ke.net Open Build Service
>
Projects
>
GFS
>
sysconfig
> sysconfig_ifdown-dhcp_dont_touch_other_ifaces_2.282033.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File sysconfig_ifdown-dhcp_dont_touch_other_ifaces_2.282033.patch of Package sysconfig (Revision 1)
Currently displaying revision
1
,
show latest
--- scripts/Makefile.am +++ scripts/Makefile.am @@ -16,7 +16,6 @@ ifup-services \ ifup-skel \ ifup-wireless \ - dhcp-interfaces \ dhcpcd-hook \ drop-hotplug-symlink.sh \ check_configurations \ --- scripts/dhcp-interfaces +++ scripts/dhcp-interfaces @@ -1,17 +0,0 @@ -#!/bin/bash - -. /etc/sysconfig/network/dhcp -: ${DHCLIENT_BIN:=dhcpcd} -if [ -x $DHCLIENT_BIN ]; then : -elif [ -x /sbin/$DHCLIENT_BIN ]; then DHCLIENT_BIN=/sbin/$DHCLIENT_BIN; -elif [ -x /sbin/dhclient ]; then DHCLIENT_BIN=/sbin/dhclient -fi -DHCLIENT=${DHCLIENT_BIN##*/} - -for i in `pidof $DHCLIENT`; do - for device in `cat -A /proc/$i/cmdline`; do - device=${device%^@} - echo -e ${device##*^@} - done -done -exit 0 --- scripts/functions +++ scripts/functions @@ -525,3 +525,36 @@ test -f $NETWORK_RUNFILE } +# returns 0 if there is a dhcp client running on this interface +# prints pids of all dhcp clients on this interface +# prints nothing if called with option '-q' +# Usually it should not happen that more then one dhcpcd is running on one +# interface, but it may happen. So better safe than sorry! +dhcpc_on_iface() { + local pid line retval=1 + while read pid line; do + retval=0 + test "$1" == "-q" && break + echo $pid + done < <(ps ax | grep -s "[ /]$DHCLIENT\>.*\<$INTERFACE\>") + return $retval +} + +# returns 0 if ifup is currently working on this interface +ifup_on_iface() { + ps ax | grep -qs "[i]fup.* $INTERFACE\>" +} + +dhcp-interfaces() { + . /etc/sysconfig/network/dhcp + : ${DHCLIENT_BIN:=dhcpcd} + if [ -x $DHCLIENT_BIN ]; then : + elif [ -x /sbin/$DHCLIENT_BIN ]; then DHCLIENT_BIN=/sbin/$DHCLIENT_BIN; + elif [ -x /sbin/dhclient ]; then DHCLIENT_BIN=/sbin/dhclient + fi + DHCLIENT=${DHCLIENT_BIN##*/} + for INTERFACE in `ls /sys/class/net`; do + dhcpc_on_iface -q && echo $INTERFACE + done + return 0 +} --- scripts/ifup-dhcp +++ scripts/ifup-dhcp @@ -34,18 +34,23 @@ exit $R_USAGE } +# returns 0 if there is a dhcp client running on this interface +# prints pids of all dhcp clients on this interface +# prints nothing if called with option '-q' +# Usually it should not happen that more then one dhcpcd is running on one +# interface, but it may happen. So better safe than sorry! dhcpc_on_iface() { - local i - for i in `pidof $DHCLIENT`; do - case $(cat /proc/$i/cmdline) in - *$INTERFACE*) return 0 - esac - done - return 1 + local pid line retval=1 + while read pid line; do + retval=0 + test "$1" == "-q" && break + echo $pid + done < <(ps ax | grep -s "[ /]$DHCLIENT\>.*\<$INTERFACE\>") + return $retval } ifup_on_iface() { - ps ax | grep -v grep | grep -qs "ifup.* $INTERFACE\>" + ps ax | grep -qs "[i]fup.* $INTERFACE\>" } ###################################################################### @@ -203,13 +208,7 @@ # let's first test if the running dhcpcd actually runs on this # interface, because then we don't want to start another one: - already_running=false - for i in `pidof $DHCLIENT`; do - case $(cat /proc/$i/cmdline) in - *$INTERFACE*) already_running=true;; - esac - done - if $already_running; then + if dhcpc_on_iface -q; then if test "$RUN_FROM_RC" = yes; then while read a b c d e f g h i; do message "`printf " %-9s IP address: %s (DHCP was already running)" $i $d`" @@ -227,12 +226,7 @@ elif [ "$ACTION" = 'renew' ]; then case $DHCLIENT in dhcpcd) - for i in `pidof $DHCLIENT`; do - case $(cat /proc/$i/cmdline) in - *$INTERFACE) dhcpcd_on_device="$dhcpcd_on_device $i" - esac - done - for i in $dhcpcd_on_device; do + for i in `dhcpc_on_iface`; do kill -TERM $i &>/dev/null done sleep 1 @@ -380,11 +374,7 @@ # interface. Unfortunately, the pid file is not there when it starts # up, so we can't rely on that. Normally, only one process is running # per interface. but we have made bad experiences with ...hotplug - for i in `pidof $DHCLIENT`; do - case $(cat /proc/$i/cmdline) in - *$INTERFACE) dhcpcd_on_device="$dhcpcd_on_device $i" - esac - done + dhcpcd_on_device="`dhcpc_on_iface`" test "$DHCLIENT_RELEASE_BEFORE_QUIT" = "yes" \ && USE_SIGNAL="-HUP" || USE_SIGNAL="-TERM" @@ -448,7 +438,7 @@ status) if test -z "`ip -o -f inet addr show $INTERFACE`"; then # interface has currently no ipv4 address assigned - if dhcpc_on_iface ; then + if dhcpc_on_iface -q; then message "`printf " %-9s %s is still waiting for data" $INTERFACE $DHCLIENT`" exit $R_DHCP_BG elif ifup_on_iface ; then @@ -460,7 +450,7 @@ fi else # interface has at least one ipv4 address - if dhcpc_on_iface ; then + if dhcpc_on_iface -q; then message "`printf " %-9s DHCP client (%s) is running" $INTERFACE $DHCLIENT`" # Show more info if not run from initscript if [ "$RUN_FROM_RC" != yes ] ; then