Re: preseed installation, hostname and PTR
On 10/08/2012 11:13 PM, Philipp Kern wrote:
On Mon, Oct 08, 2012 at 09:20:47PM +0200, Floris Bos / Maxnet wrote:
Deja vu: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=606636
To me it is still a bug, although others mentioned it is documented
behavior.
It is. However that patch would need to be redone against Matt's changes
to netcfg.
Attached a new one, so that excuse can no longer be used.
Yours sincerely,
Floris Bos
diff -ur netcfg-1.98.orig/debian/netcfg-common.templates netcfg-1.98/debian/netcfg-common.templates
--- netcfg-1.98.orig/debian/netcfg-common.templates 2012-10-03 01:23:27.000000000 +0200
+++ netcfg-1.98/debian/netcfg-common.templates 2012-10-09 01:34:16.287439267 +0200
@@ -152,6 +152,12 @@
administrator. If you are setting up your own home network, you can make
something up here.
+Template: netcfg/hostname
+Type: string
+Description: Hostname that can be preseeded.
+ .
+ If specified this disables the automatic detection of the hostname by netcfg.
+
Template: netcfg/invalid_hostname
Type: error
# :sl2:
Only in netcfg-1.98/debian: netcfg.debhelper.log
Only in netcfg-1.98/debian: netcfg-static.debhelper.log
diff -ur netcfg-1.98.orig/dhcp.c netcfg-1.98/dhcp.c
--- netcfg-1.98.orig/dhcp.c 2012-09-25 02:07:24.000000000 +0200
+++ netcfg-1.98/dhcp.c 2012-10-09 01:57:22.055463420 +0200
@@ -559,12 +559,19 @@
{
char buf[MAXHOSTNAMELEN + 1] = { 0 };
/*
- * Default to the hostname returned via DHCP, if any,
+ * If the netcfg/hostname preseed value is set use that
+ * otherwise default to the hostname returned via DHCP, if any,
* otherwise to the requested DHCP hostname
* otherwise to the hostname found in DNS for the IP address
* of the interface
*/
- if (gethostname(buf, sizeof(buf)) == 0
+ debconf_get(client, "netcfg/hostname");
+ if (!empty_str(client->value))
+ {
+ strncpy(buf, client->value, MAXHOSTNAMELEN);
+ preseed_hostname_from_fqdn(client, buf);
+ }
+ else if (gethostname(buf, sizeof(buf)) == 0
&& !empty_str(buf)
&& strcmp(buf, "(none)")
) {
diff -ur netcfg-1.98.orig/static.c netcfg-1.98/static.c
--- netcfg-1.98.orig/static.c 2012-10-04 23:14:35.000000000 +0200
+++ netcfg-1.98/static.c 2012-10-09 01:58:14.375464370 +0200
@@ -608,8 +608,15 @@
break;
case GET_HOSTNAME:
{
- char buf[MAXHOSTNAMELEN + 1];
- if (get_hostname_from_dns(iface, buf, sizeof(buf)))
+ char buf[MAXHOSTNAMELEN + 1] = { 0 };
+
+ debconf_get(client, "netcfg/hostname");
+ if (!empty_str(client->value))
+ {
+ strncpy(buf, client->value, MAXHOSTNAMELEN);
+ preseed_hostname_from_fqdn(client, buf);
+ }
+ else if (get_hostname_from_dns(iface, buf, sizeof(buf)))
preseed_hostname_from_fqdn(client, buf);
}
state = (netcfg_get_hostname(client, "netcfg/get_hostname", hostname, 1)) ?
Reply to: