dhcpcd-discuss

RE: Does old_fqdn take on the value of new_dhcp6_fqdn?

Roy Marples

Sat Aug 15 00:20:02 2015

Hi Paul

On 2015-08-15 00:52, Walrath, Paul wrote:
I'm seeing another unexplainable behavior that may be tied in with
this.  If I change my DHCP servers from the DHCPv6 server providing
DHCPv6 Option 39 Client FQDN to having the DHCPv4 server providing
DHCPv4 Option 12 Hostname and DHCPv4 Option 15 Domain Name to my
device then do an ifdown followed by an ifup on my device's network
interface, the domain name changes (/etc/resolv.conf) to the DHCPv4
provided name but the host name remains the same.  If I power-cycle my
device, the host name gets updated.

This won't work, dhcpcd won't magically unset the hostname, thus probably won't change over. I don't see a good way of doing this, but not thought about it too much either.

I can make the host name get updated with just the ifdown/ifup
sequence by making the following change in 30-hostname in the
set_hostname function:

Existing code:

set_hostname()
{
	local hfqdn=false hshort=false

	need_hostname || return

New code:

set_hostname()
{
	local hfqdn=false hshort=false

	if [ need_hostname ]; then
		# Walrath: Debug
		printf "NEEDED\n" >> /var/log/rpw
	else
		# Walrath: Debug
		printf "NOT NEEDED\n" >> /var/log/rpw
		return
	fi

I'm using the shell from Busybox (which is called ash).

It appears as though the "if [ need_hostname] " method is more
reliable.  Don't ask me why.  I did some printf tracing and here's
what it showed:

It's wrong, as this snippet shows

$ cat x
#!/bin/sh

foo1()
{
        return 1
}

foo1 && echo bar1
[ foo1 ] && echo bar2


foo2()
{
        return 0
}

foo2 && echo bar21
[ foo2 ] && echo bar22

foo3 && echo bar31
[ foo3 ] && echo bar32

$ sh ./x
bar2
bar21
bar22
foo3: not found
bar32
$

Roy

Follow-Ups:
Re: Does old_fqdn take on the value of new_dhcp6_fqdn?Roy Marples
RE: Does old_fqdn take on the value of new_dhcp6_fqdn?Walrath, Paul
References:
Does old_fqdn take on the value of new_dhcp6_fqdn?Walrath, Paul
Re: Does old_fqdn take on the value of new_dhcp6_fqdn?Roy Marples
RE: Does old_fqdn take on the value of new_dhcp6_fqdn?Walrath, Paul
Archive administrator: postmaster@marples.name