Discussion:
Bug#682342: netcfg DHCP information handling regression between Lenny and Squeeze
Add Reply
Roy Hills
2012-07-21 20:40:02 UTC
Reply
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Package: netcfg
Version: 1.59

I'm using PXE boot with network preseeding to perform automated Debian
installations with Lenny, Squeeze and Wheezy.

With Lenny, netcfg used the DHCP options domain-name,
domain-name-servers, and ntp-servers. With Squeeze and Wheezy, these
options seem to be ignored.

I have the following in my DHCP configuration file, dhcpd.conf:

option domain-name "training.nta-monitor.com";
option domain-name-servers ns0.training.nta-monitor.com;
option ntp-servers ntp0.training.nta-monitor.com;

And I'm using the following boot parameters in the PXE configuration file:

append vga=normal initrd=debian/lenny/i386/initrd.gz
hostname=unassigned domain=unassigned netcfg/no_default_route=true
auto=true url=http://10.0.57.1/debian/d-i/lenny/preseed.cfg
DEBCONF_DEBUG=5

For Lenny, this works fine. In particular the domain name gets set
from the DHCP "domain-name" option, the DNS servers get set from
"domain-name-servers", and the system sets the time from the NTP
server specified by the "ntp-servers" option.

For Squeeze, these boot parameters (appropriately changed to use the
Squeeze preseed URL) result in the domain name getting set to
"unassigned", the installer prompting for the DNS servers, and the
system trying to use the default Debian NTP servers (and failing
because I'm behind a proxy with no direct Internet access).

Wheezy shows the same behaviour as Squeeze.

I can specify these parameters by adding the appropriate additional
parameters to the boot options, but this is not ideal as I'd like to
store the information in the DHCP configuration so it's just in one place.

I think this is a regression in netcfg some time between Lenny and
Squeeze.

I notice the following changelog entry for netcfg 1.48:

* Refactor dhcp configuration code.

Could that be the culprit I wonder?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlALDrQACgkQy4enOlZ7nzpw6QCeOyTYnCafj0eIpkSB+dnBhKWB
k80An34LxUlU599Sxprp1395LPgUyTVm
=6HUK
-----END PGP SIGNATURE-----
--
To UNSUBSCRIBE, email to debian-bugs-dist-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Nishanth Aravamudan
2019-08-14 16:10:01 UTC
Reply
Permalink
We are able to reproduce this issue at will in Ubuntu Bionic's installer
(not identical to Debian's, but code-wise in this path the same).
While quite a while after the last update from Philipp, we tested the
patch (netcfg_dhcp_domain.patch) after updating it to avoid a
compilation issue, we found it did fix the problem for us.

I am not sure if I can get Debian into our infrastructure to test
explicitly, but I will work on it; at the same time, the code change
seems straightforward.

Thanks!
-Nish
Cyril Brulebois
2019-08-15 15:20:01 UTC
Reply
Permalink
Hi,
Post by Nishanth Aravamudan
We are able to reproduce this issue at will in Ubuntu Bionic's
installer (not identical to Debian's, but code-wise in this path the
same). While quite a while after the last update from Philipp, we
tested the patch (netcfg_dhcp_domain.patch) after updating it to avoid
a compilation issue, we found it did fix the problem for us.
I am not sure if I can get Debian into our infrastructure to test
explicitly, but I will work on it; at the same time, the code change
seems straightforward.
Thanks for your feedback. Care to share the fixed version? :)

I'm a little reluctant to blindly merging this patch (originally
labeled “untested”) without a go from its author. Philipp, should
I go ahead?


Cheers,
--
Cyril Brulebois (***@debian.org) <https://debamax.com/>
D-I release manager -- Release team member -- Freelance Consultant
Nishanth Aravamudan
2019-08-16 18:40:01 UTC
Reply
Permalink
Post by Cyril Brulebois
Hi,
Post by Nishanth Aravamudan
We are able to reproduce this issue at will in Ubuntu Bionic's
installer (not identical to Debian's, but code-wise in this path the
same). While quite a while after the last update from Philipp, we
tested the patch (netcfg_dhcp_domain.patch) after updating it to avoid
a compilation issue, we found it did fix the problem for us.
I am not sure if I can get Debian into our infrastructure to test
explicitly, but I will work on it; at the same time, the code change
seems straightforward.
Thanks for your feedback. Care to share the fixed version? :)
D'oh! I'm sorry, I thought I did. The patch we tested was:

diff -Naur a/dhcp.c b/dhcp.c
--- a/dhcp.c 2017-10-10 14:01:42.000000000 +0000
+++ b/dhcp.c 2019-08-14 01:04:58.339325357 +0000
@@ -590,7 +590,7 @@
preseed_hostname_from_fqdn(client, buf);
}

- if (netcfg_get_hostname (client, "netcfg/get_hostname", hostname, 1)) {
+ if (netcfg_get_hostname (client, "netcfg/get_hostname", hostname, !have_domain)) {
/*
* Going back to POLL wouldn't make much sense.
* However, it does make sense to go to the retry
diff -Naur a/netcfg-common.c b/netcfg-common.c
--- a/netcfg-common.c 2017-10-10 14:04:08.000000000 +0000
+++ b/netcfg-common.c 2019-08-13 20:01:13.606510273 +0000
@@ -1060,14 +1060,24 @@
continue;
}

- if (accept_domain && (s = strchr(hostname, '.'))) {
- di_info("Detected we have an FQDN; splitting and setting domain");
- if (s[1] == '\0') { /* "somehostname." <- . should be ignored */
+ if ((s = strchr(hostname, '.'))) {
+ di_info("Detected an FQDN in hostname");
+ if (s[1] == '\0') {
+ /* "somehostname." <- . should be ignored */
*s = '\0';
- } else { /* assume we have a valid domain name given */
- strncpy(domain, s + 1, MAXHOSTNAMELEN);
- debconf_set(client, "netcfg/get_domain", domain);
- have_domain = 1;
+ di_info("Stripped trailing dot from hostname");
+ } else {
+ /* assume that the domain is valid and copy it if
+ * accept_domain is set; just use the hostname if
+ * it is unset
+ */
+ if (accept_domain) {
+ strncpy(domain, s + 1, MAXHOSTNAMELEN);
+ di_info("Setting domain to %s", domain);
+ debconf_set(client, "netcfg/get_domain", domain);
+ have_domain = 1;
+ }
+ /* strip the domain from the hostname */
*s = '\0';
}
}
Post by Cyril Brulebois
I'm a little reluctant to blindly merging this patch (originally
labeled “untested”) without a go from its author. Philipp, should
I go ahead?
Totally understood! I just wanted to make sure to revive this issue, as
I'd also like to get it fixed in Ubuntu! Like I said, I will do my best
to test and reproduce the fix with stock Debian.

-Nish
Nishanth Aravamudan
2019-10-09 21:00:02 UTC
Reply
Permalink
Post by Nishanth Aravamudan
Post by Cyril Brulebois
Post by Nishanth Aravamudan
We are able to reproduce this issue at will in Ubuntu Bionic's
installer (not identical to Debian's, but code-wise in this path the
same). While quite a while after the last update from Philipp, we
tested the patch (netcfg_dhcp_domain.patch) after updating it to avoid
a compilation issue, we found it did fix the problem for us.
I am not sure if I can get Debian into our infrastructure to test
explicitly, but I will work on it; at the same time, the code change
seems straightforward.
Thanks for your feedback. Care to share the fixed version? :)
diff -Naur a/dhcp.c b/dhcp.c
--- a/dhcp.c 2017-10-10 14:01:42.000000000 +0000
+++ b/dhcp.c 2019-08-14 01:04:58.339325357 +0000
@@ -590,7 +590,7 @@
preseed_hostname_from_fqdn(client, buf);
}
- if (netcfg_get_hostname (client, "netcfg/get_hostname", hostname, 1)) {
+ if (netcfg_get_hostname (client, "netcfg/get_hostname", hostname, !have_domain)) {
/*
* Going back to POLL wouldn't make much sense.
* However, it does make sense to go to the retry
diff -Naur a/netcfg-common.c b/netcfg-common.c
--- a/netcfg-common.c 2017-10-10 14:04:08.000000000 +0000
+++ b/netcfg-common.c 2019-08-13 20:01:13.606510273 +0000
@@ -1060,14 +1060,24 @@
continue;
}
- if (accept_domain && (s = strchr(hostname, '.'))) {
- di_info("Detected we have an FQDN; splitting and setting domain");
- if (s[1] == '\0') { /* "somehostname." <- . should be ignored */
+ if ((s = strchr(hostname, '.'))) {
+ di_info("Detected an FQDN in hostname");
+ if (s[1] == '\0') {
+ /* "somehostname." <- . should be ignored */
*s = '\0';
- } else { /* assume we have a valid domain name given */
- strncpy(domain, s + 1, MAXHOSTNAMELEN);
- debconf_set(client, "netcfg/get_domain", domain);
- have_domain = 1;
+ di_info("Stripped trailing dot from hostname");
+ } else {
+ /* assume that the domain is valid and copy it if
+ * accept_domain is set; just use the hostname if
+ * it is unset
+ */
+ if (accept_domain) {
+ strncpy(domain, s + 1, MAXHOSTNAMELEN);
+ di_info("Setting domain to %s", domain);
This needs indenting fix-up.
Thank you, fixed below, I believe.

diff -Naur a/dhcp.c b/dhcp.c
--- a/dhcp.c 2017-10-10 14:01:42.000000000 +0000
+++ b/dhcp.c 2019-08-14 01:04:58.339325357 +0000
@@ -590,7 +590,7 @@
preseed_hostname_from_fqdn(client, buf);
}

- if (netcfg_get_hostname (client, "netcfg/get_hostname", hostname, 1)) {
+ if (netcfg_get_hostname (client, "netcfg/get_hostname", hostname, !have_domain)) {
/*
* Going back to POLL wouldn't make much sense.
* However, it does make sense to go to the retry
diff -Naur a/netcfg-common.c b/netcfg-common.c
--- a/netcfg-common.c 2017-10-10 14:04:08.000000000 +0000
+++ b/netcfg-common.c 2019-08-13 20:01:13.606510273 +0000
@@ -1060,14 +1060,24 @@
continue;
}

- if (accept_domain && (s = strchr(hostname, '.'))) {
- di_info("Detected we have an FQDN; splitting and setting domain");
- if (s[1] == '\0') { /* "somehostname." <- . should be ignored */
+ if ((s = strchr(hostname, '.'))) {
+ di_info("Detected an FQDN in hostname");
+ if (s[1] == '\0') {
+ /* "somehostname." <- . should be ignored */
*s = '\0';
- } else { /* assume we have a valid domain name given */
- strncpy(domain, s + 1, MAXHOSTNAMELEN);
- debconf_set(client, "netcfg/get_domain", domain);
- have_domain = 1;
+ di_info("Stripped trailing dot from hostname");
+ } else {
+ /* assume that the domain is valid and copy it if
+ * accept_domain is set; just use the hostname if
+ * it is unset
+ */
+ if (accept_domain) {
+ strncpy(domain, s + 1, MAXHOSTNAMELEN);
+ di_info("Setting domain to %s", domain);
+ debconf_set(client, "netcfg/get_domain", domain);
+ have_domain = 1;
+ }
+ /* strip the domain from the hostname */
*s = '\0';
}
}

Loading...