dhclient-exit-hooks

Daniel Bye freebsd-questions at slightlystrange.org
Thu May 4 13:11:01 UTC 2006


(Apologies for the rather fragmentary nature of this post - I've been
typing and reading  the scripts and man pages, trying to get my head round
what's going on...)

On Wed, May 03, 2006 at 05:43:48PM -0400, fbsd wrote:
> I figured the "Shared object not found" error is another sign
> of what is wrong in general so I commented out the mail command
> to concentrate on just the logger problem. 

Fair enough - we'll come back to this later!

> During testing the
> logger problem I determined the script "if" statement is not
> working.

It ought to - the test is structured correctly, so I can't see any
reason it would not behave in any way other than you would expect.

> Problem seems more like bug in how and or when during the boot
> process the script is getting executed.

Yeah, it's beginning to look like it, isn't it?  Did you try running it
with xtrace turned on?  Perhaps you could even try running rc under
xtrace?  (I have done this in the past, it spews forth a great deal of
noise, but among the noise you may find what you are looking for.)

> This has nothing to do with my script code.
> This is how FreeBSD is handling the default dhclient-script that
> comes pre installed on the system.
> 
> The recorder directives have made no difference.

Yep, that makes sense - now I understand where your code is being called
from.

> Please note I am not using the isc-dhcp port dhclient.
> I am running the dhclient that comes as part of the base
> install of FreeBSD.

Noted.

> I have ifconfig_dc0="DHCP" in rc.conf to launch
> /sbin/dhclient-script.
> dhclient-script calls dhclient-exit-hooks

> I don't think the recorder directives get into play because
> dhclient does not use the rc.d environment.

No, not the ones you added to the dhclient-exit-hooks, but dhclient is
started by this block of code in /etc/network.subr:

        if dhcpif $1; then
                if [ $_cfg -ne 0 ] ; then
                        ifconfig $1 up
                fi
                /etc/rc.d/dhclient start $1
                _cfg=0
        fi

(dhcpif() tests the value of $1, returning true if it is DHCP or dhcp or
any combination in mixed case)

/etc/network.subr gets called from /etc/rc.d/netif (among others, but it
is netif that is called earliest, I believe).

/etc/rc.d/dhclient does use rcorder, although you are right in that
/sbin/dhclient doesn't know anything about it.

As far as I can tell, the sequence of events is something like this:

rc builds a list of files to run, using rcorder(8)

These scripts run, occasionally calling in other helper scripts (such as
/etc/network.subr).

When netif is called, it calls network.subr, which calls
/etc/rc.d/dhclient as necessary.

/etc/rc.d/dhclient starts /sbin/dhclient, which in turn calls
/sbin/dhclient-script at various points in its execution.

/sbin/dhclient-script then calls the enter and exit hooks at the
appropriate times.


> I know the dhclient-exit-hooks script is executing because of the
> echo commands I put in it before and after the IF statement.

Yep, that's fair comment.

> I also know the dhclient variables are being loaded in the
> /etc/dhcpd.name-servers file because I empty it before rebooting
> system, and after words I edit it and it contains the correct
> values.

Which suggests that your code is indeed Doing the Right Thing.

> I am beginning to think that something changed between 4.x and 6.0
> in
> the way the dhclient-script get processed during boot.
> It's acting like it gets executed to early in the boot process.
> Do I have enough evidence on this to submit a bug report???

I reckon it's worth trying under xtrace to see if that provides any clue.

You could also try adding -s to the logger call, so it prints its
messages to STDERR as well as to the nominated log file.

Dan

-- 
Daniel Bye

PGP Key: ftp://ftp.slightlystrange.org/pgpkey/dan.asc
PGP Key fingerprint: D349 B109 0EB8 2554 4D75  B79A 8B17 F97C 1622 166A
                                                                     _
                                              ASCII ribbon campaign ( )
                                         - against HTML, vCards and  X
                                - proprietary attachments in e-mail / \
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20060504/16737b52/attachment.pgp


More information about the freebsd-questions mailing list