Subject: Re: install/22044: missing domainname in rc.conf
To: None <netbsd-bugs@netbsd.org>
From: William Allen Simpson <wsimpson@greendragon.com>
List: netbsd-bugs
Date: 07/03/2003 20:40:08
I've spent a bit of time looking at the history, and found another
error.
Basically, recent programmers assumed that the net_host is a superset
of net_domain. In reality, they are two separate fields in the menu,
and not related at all!
See get_ifinterface_info:
/* split hostname into host/domain parts */
size_t max_len = dot - hostname;
max_len = (sizeof(net_host)<max_len)?sizeof(net_host):max_len;
*dot = '\0';
dot++;
strncpy(net_host, hostname, max_len);
max_len = strlen(dot);
max_len = (sizeof(net_host)<max_len)?sizeof(net_host):max_len;
strncpy(net_domain, dot, max_len);
And config_network:
msg_prompt_add(MSG_net_domain, net_domain, net_domain, STRSIZE);
msg_prompt_add(MSG_net_host, net_host, net_host, STRSIZE);
Therefore,
/* Write hostname to /etc/rc.conf */
if ((net_dhcpconf & DHCPCONF_HOST) == 0)
add_rc_conf("hostname=%s\n", net_host);
*NEVER* has the domain part!
Unfortunately, note the comparisons here:
/*
* write the new contents of /etc/hosts to the specified file
*/
static void
write_etc_hosts(FILE *f)
{
int l;
scripting_fprintf(f, "#\n");
scripting_fprintf(f, "# Added by NetBSD sysinst\n");
scripting_fprintf(f, "#\n");
scripting_fprintf(f, "127.0.0.1 localhost\n");
scripting_fprintf(f, "%s\t", net_ip);
l = strlen(net_host) - strlen(net_domain);
if (l <= 0 ||
net_host[l - 1] != '.' ||
strcasecmp(net_domain, net_host + l) != 0) {
/* net_host isn't an FQDN. */
scripting_fprintf(f, "%s.%s ", net_host, net_domain);
}
scripting_fprintf(f, "%s\n", net_host);
}
This code is completely bogus, since the net_host never has the
net_domain in it. But it works (on bad assumptions), because
net_host[l - 1] != '.' is always true!
--
William Allen Simpson
Key fingerprint = 17 40 5E 67 15 6F 31 26 DD 0D B9 9B 6A 15 2C 32