Subject: Re: sendmail problems
To: Jan Danielsson <jan.m.danielsson@gmail.com>
From: Steven M. Bellovin <smb@cs.columbia.edu>
List: netbsd-users
Date: 02/02/2007 14:59:35
On Fri, 02 Feb 2007 10:58:56 +0100
Jan Danielsson <jan.m.danielsson@gmail.com> wrote:

> Hauke Fath wrote:
> >>    One of the problems is that the DHCP server that this computer
> >> connects to, doesn't seem to send out 'hostname'.
> > 
> > What dhcp server? And do you have access to that?
> 
>    Sorry, I should have been more specific. It's an ISP -- so I do not
> have access to the server in question, unfortunately.
> 
>    Now that I started writing this stuff again, I believe that the
> problem I had before was in fact that "sed" is in "/usr/bin", but /usr
> hasn't been mounted when dhclient-enter-hook is run the first time
> (during boot). Is there an assumption made that the dhcp server
> *should* pass hostname, and therefore no parsing tools are made
> available during the initial run of dhclient-enter-hook?
> 
>    Although I personally feel that hostname should be supplied by the
> dhcpd, neither this particular ISP, nor the one I use here (they are
> different) do pass hostname information to the clients.
> 
>    I have this thing about moving around system utilities.. I don't
> like it. One solution would obviously be to simply copy /usr/bin/sed
> to /bin/sed -- but I would really prefer not to, if possible. I kind
> of anal about those things, unfortunately.
> 
>    At the same time.. I - again - have the feeling that this is a
> problem which probably has been solved a thousand times before --
> which makes me not want to put too much effort into it.
> 
> > Setting 'option host-name "foo";' in the dhcpd.conf, and 'request
> > [...],host-name, [...]' in /etc/dhclient.conf handles things nicely
> > for me. I don't bother with an /etc/hosts entry, though.
> 
>    Pehaps they do send out host-name if requested nowadays. I'm 100%
> sure I did try it previously, but it didn't work then.
> 
>    Ugh, nope -- they still don't supply host-name. Curious, though.. I
> noticed a new dhclient.conf keyword I hadn't seen before: "require".
> So I set "require host-name", but it didn't do anything -- not even
> protest.
> 
You can do several things.  (I understand your problem; I had analogous
issues with some old scripts of mine.)

First option -- rewrite your script.  Sed is the easy way to do certain
things, but with a bit of effort you can use shell, expr, and/or ed
instead.  (You may also need to mount /tmp early or create something
like /var/tmp as a temporary file place.

Second -- change your /etc/rc.conf file to add /usr to
critical_filesystems_local -- see /etc/defaults/rc.conf for details.
This is probably the easiest solution for folks who don't
mount /usr via NFS.  (Alternatively, you could edit the REQUIRES: line
in /etc/rc.d/dhclient so that it invokes mountcritremote first. But
that might cause a dependency loop; I haven't tried it.)

Third -- and this depends on why you need your ISP's notion of your
hostname -- get your own domain, and use DNS Dynamic Update to point
your machine's name to your current IP address.  If you need a script
to do that -- and you might -- you can probably put it
in /etc/rc.local, unless you think that your mailer is going to get
busy too soon.  There is some reason to think this might not work; it's
possible that some anti-spam filters might be concerned that your
hostname doesn't match what the PTR record says.


		--Steve Bellovin, http://www.cs.columbia.edu/~smb