ifup/down broken!!!

Denys Vlasenko vda.linux at googlemail.com
Tue Sep 27 19:30:46 UTC 2016


On Tue, Sep 27, 2016 at 2:44 PM, David Henderson
<dhenderson at digital-pipe.com> wrote:
> On 9/27/16, dietmar.schindler at manroland-web.com
> <dietmar.schindler at manroland-web.com> wrote:
>>> Von: David Henderson
>>> Gesendet: Montag, 26. September 2016 17:04
>>>
>>> ...  The script is as follows:
>>>
>>> #!/bin/sh
>>> #
>>> # DEBUG
>>> echo 'resolv.conf' > /tmp/debug.ifup
>>> env >> /tmp/debug.ifup
>>>
>>> # everything below this point was added recently
>>> CONFIG=''
>>>
>>> # this segment was what was causing an exit 1
>>> [ -e '/etc/network/interfaces' ] && ( echo "$IFACE" | grep -q ':' ) && {
>>>         [ "$IF_DNS_DOMAIN" ] && CONFIG="${CONFIG}domain
>>> ${IF_DNS_DOMAIN}\n"
>>>         [ "$IF_DNS_SEARCH" ] && CONFIG="${CONFIG}search
>>> ${IF_DNS_SEARCH}\n"
>>>         [ "$IF_DNS_SORTLIST" ] && CONFIG="${CONFIG}sortlist
>>> ${IF_DNS_SORTLIST}\n"
>>>         for NS in $IF_DNS_NAMESERVER $IF_DNS_NAMESERVERS; do
>>>                 CONFIG="${CONFIG}nameserver $NS\n"
>>>         done
>>> }
>>> [ "$CONFIG" != '' ] && echo -e "$CONFIG" > /etc/resolv.conf
>>>
>>>
>>> The "[ -e '/etc/network/interfaces' ] && ..." section was the part
>>> that appears to be causing the 'exit 1' status - most likely from the
>>> 'grep -q ':'' call.  Does this indicate an issue with /bin/sh as the
>>> normal exit value of the script should be 0?  It appears that the
>>> 'grep' call is returning a false response that is being retained and
>>> causing the 'exit 1' status of the script even though the script
>>> continues to process until the end (which should be an exit 0 now
>>> right?)...
>>
>> Why does it appear to you that the next-to-last command dictates the
>> script's exit status? That is implausible. In fact, the last command's exit
>> status is also the script's exit status, so most probably the test [
>> "$CONFIG" != '' ] returns 1 (false) because $CONFIG is empty.
>> --
>> Regards,
>> Dietmar Schindler
>
> Good morning Dietmar, thanks for the reply to this.  The reason I
> believe that is because I commented out the "[ 'CONFIG' != '' ]" line
> and nothing changed.  I then commented out the next block above it,
> which did stop the 'exit 1' status from 'ifup'.  I find it wierd that
> that was the case too, but it was.

Thus, the reason for ifup not working for you was
/etc/network/if-up.d/000_dns-nameservers
exiting with nonzero exit code, i.e. it was signaling a failure to ifup,
which in turn was deciding that "upping eth0 failed",
and wasn't writing /var/run/ifstate.

Your strace output shows that when that problem is resolved,
/var/run/ifstate is successfully updated:

18287 19:38:45.666707 open("/var/run/ifstate", O_RDONLY|O_LARGEFILE) = 3
18287 19:38:45.666769 fstat64(3, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
18287 19:38:45.666908 read(3, "", 4096) = 0
18287 19:38:45.666957 close(3)          = 0
18287 19:38:45.667059 open("/var/run/ifstate",
O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
18287 19:38:45.667132 fstat64(3, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
18287 19:38:45.667261 write(3, "eth0=eth0\n", 10) = 10
18287 19:38:45.667319 close(3)          = 0


More information about the busybox mailing list