Bug#177666: updated patch
Howdy,
The appended patch includes the previous one, and fixes /etc/hosts
when using DHCP.
Matt
diff -ur debian-installer.orig/tools/netcfg/debian/rules debian-installer/tools/netcfg/debian/rules
--- debian-installer.orig/tools/netcfg/debian/rules 2002-10-20 14:28:46.000000000 -0700
+++ debian-installer/tools/netcfg/debian/rules 2003-01-21 08:29:36.000000000 -0800
@@ -49,6 +49,12 @@
cp netcfg-static debian/netcfg-static.postinst
mkdir -p debian/netcfg-dhcp/etc/dhcp debian/netcfg-dhcp/var/dhcp
mkdir -p debian/netcfg-static/etc/network
+ mkdir -p debian/netcfg-dhcp/usr/lib/prebaseconfig.d
+ install -m 755 debian/prebaseconfig \
+ debian/netcfg-dhcp/usr/lib/prebaseconfig.d/40netcfg-dhcp
+ mkdir -p debian/netcfg-static/usr/lib/prebaseconfig.d
+ install -m 755 debian/prebaseconfig \
+ debian/netcfg-static/usr/lib/prebaseconfig.d/40netcfg-static
# Build architecture-independent files here.
binary-indep: build install
diff -ur debian-installer.orig/tools/netcfg/netcfg-dhcp.c debian-installer/tools/netcfg/netcfg-dhcp.c
--- debian-installer.orig/tools/netcfg/netcfg-dhcp.c 2003-01-11 19:54:45.000000000 -0800
+++ debian-installer/tools/netcfg/netcfg-dhcp.c 2003-01-21 13:34:12.000000000 -0800
@@ -85,9 +85,10 @@
FILE *fp;
- if ((fp = file_open(INTERFACES_FILE))) {
+ if ((fp = file_open(INTERFACES_FILE, "a"))) {
fprintf(fp,
"\n# This entry was created during the Debian installation\n");
+ fprintf(fp, "auto %s\n", interface);
fprintf(fp, "iface %s inet dhcp\n", interface);
if (dhcp_hostname)
fprintf(fp, "\thostname %s\n", dhcp_hostname);
@@ -154,13 +155,13 @@
do {
netcfg_get_interface(client, &interface);
+ netcfg_get_hostname(client, &hostname);
client->command(client, "subst", "netcfg/confirm_dhcp",
"interface", interface, NULL);
client->command(client, "subst", "netcfg/confirm_dhcp",
- "hostname", (hostname ? hostname : _("<none>")),
- NULL);
+ "hostname", hostname, NULL);
client->command(client, "subst", "netcfg/confirm_dhcp",
"domain", (domain ? domain : _("<none>")),
@@ -182,8 +183,9 @@
}
while (!finished);
+ netcfg_write_common("40netcfg-dhcp", ipaddress, domain, hostname,
+ nameserver_array);
netcfg_write_dhcp();
- netcfg_write_common(ipaddress, domain, hostname, nameserver_array);
my_debconf_input("medium", "netcfg/do_dhcp");
netcfg_activate_dhcp();
diff -ur debian-installer.orig/tools/netcfg/netcfg-static.c debian-installer/tools/netcfg/netcfg-static.c
--- debian-installer.orig/tools/netcfg/netcfg-static.c 2002-12-13 12:03:35.000000000 -0800
+++ debian-installer/tools/netcfg/netcfg-static.c 2003-01-21 08:50:11.000000000 -0800
@@ -122,17 +122,22 @@
{
FILE *fp;
- if ((fp = file_open(NETWORKS_FILE))) {
+ if ((fp = file_open(NETWORKS_FILE, "w"))) {
fprintf(fp, "localnet %s\n", num2dot(network));
fclose(fp);
+
+ di_prebaseconfig_append("40netcfg-static", "cp %s %s\n",
+ NETWORKS_FILE,
+ "/target" NETWORKS_FILE);
} else
goto error;
- if ((fp = file_open(INTERFACES_FILE))) {
+ if ((fp = file_open(INTERFACES_FILE, "a"))) {
fprintf(fp,
"\n# This entry was created during the Debian installation\n");
fprintf(fp,
"# (network, broadcast and gateway are optional)\n");
+ fprintf(fp, "auto %s\n", interface);
fprintf(fp, "iface %s inet static\n", interface);
fprintf(fp, "\taddress %s\n", num2dot(ipaddress));
fprintf(fp, "\tnetmask %s\n", num2dot(netmask));
@@ -245,7 +250,8 @@
}
while (!finished);
- netcfg_write_common(ipaddress, domain, hostname, nameserver_array);
+ netcfg_write_common("40netcfg-static", ipaddress, domain, hostname,
+ nameserver_array);
netcfg_write_static();
netcfg_activate_static();
diff -ur debian-installer.orig/tools/netcfg/netcfg.c debian-installer/tools/netcfg/netcfg.c
--- debian-installer.orig/tools/netcfg/netcfg.c 2002-12-13 12:03:35.000000000 -0800
+++ debian-installer/tools/netcfg/netcfg.c 2003-01-21 13:48:34.000000000 -0800
@@ -181,10 +181,10 @@
}
-FILE *file_open(char *path)
+FILE *file_open(char *path, const char *opentype)
{
FILE *fp;
- if ((fp = fopen(path, "w")))
+ if ((fp = fopen(path, opentype)))
return fp;
else {
fprintf(stderr, "%s\n", path);
@@ -325,18 +325,13 @@
netcfg_die(client);
}
-
void
-netcfg_get_common(struct debconfclient *client, char **interface,
- char **hostname, char **domain, char **nameservers)
+netcfg_get_hostname(struct debconfclient *client, char **hostname)
{
- char *ptr;
static const char *valid_chars =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-";
size_t len;
- netcfg_get_interface(client, interface);
-
do {
free(*hostname);
@@ -364,8 +359,18 @@
}
} while (!*hostname);
+}
+void
+netcfg_get_common(struct debconfclient *client, char **interface,
+ char **hostname, char **domain, char **nameservers)
+{
+ char *ptr;
+
+ netcfg_get_interface(client, interface);
+ netcfg_get_hostname(client, hostname);
+
free(*domain);
*domain = NULL;
@@ -409,15 +414,24 @@
void
-netcfg_write_common(u_int32_t ipaddress, char *domain, char *hostname,
- u_int32_t nameservers[])
+netcfg_write_common(const char *prebaseconfig, u_int32_t ipaddress,
+ char *domain, char *hostname, u_int32_t nameservers[])
{
FILE *fp;
+ if ((fp = file_open(INTERFACES_FILE, "w"))) {
+ fprintf(fp, "auto lo\n");
+ fprintf(fp, "iface lo inet loopback\n");
+ fclose(fp);
+
+ di_prebaseconfig_append(prebaseconfig, "cp %s %s\n",
+ INTERFACES_FILE,
+ "/target" INTERFACES_FILE);
+ }
- if ((fp = file_open(HOSTS_FILE))) {
- fprintf(fp, "127.0.0.1\tlocalhost\n");
+ if ((fp = file_open(HOSTS_FILE, "w"))) {
if (ipaddress) {
+ fprintf(fp, "127.0.0.1\tlocalhost\n");
if (domain)
fprintf(fp, "%s\t%s.%s\t%s\n",
num2dot(ipaddress), hostname,
@@ -425,12 +439,17 @@
else
fprintf(fp, "%s\t%s\n", num2dot(ipaddress),
hostname);
- }
+ } else {
+ fprintf(fp, "127.0.0.1\t%s\tlocalhost\n", hostname);
+ }
fclose(fp);
+
+ di_prebaseconfig_append(prebaseconfig, "cp %s %s\n",
+ HOSTS_FILE, "/target" HOSTS_FILE);
}
- if ((fp = file_open(RESOLV_FILE))) {
+ if ((fp = file_open(RESOLV_FILE, "w"))) {
int i = 0;
if (domain)
fprintf(fp, "search %s\n", domain);
@@ -440,5 +459,8 @@
num2dot(nameservers[i++]));
fclose(fp);
+
+ di_prebaseconfig_append(prebaseconfig, "cp %s %s\n",
+ RESOLV_FILE, "/target" RESOLV_FILE);
}
}
diff -ur debian-installer.orig/tools/netcfg/netcfg.h debian-installer/tools/netcfg/netcfg.h
--- debian-installer.orig/tools/netcfg/netcfg.h 2002-12-03 12:51:52.000000000 -0800
+++ debian-installer/tools/netcfg/netcfg.h 2003-01-21 13:49:06.000000000 -0800
@@ -31,7 +31,7 @@
extern char *get_ifdsc (const char *ifp);
-extern FILE *file_open (char *path);
+extern FILE *file_open (char *path, const char *opentype);
extern void dot2num (u_int32_t * num, char *dot);
@@ -41,11 +41,14 @@
extern void netcfg_get_interface(struct debconfclient *client, char **interface);
+extern void netcfg_get_hostname(struct debconfclient *client, char **hostname);
+
extern void netcfg_get_common (struct debconfclient *client, char **interface,
char **hostname, char **domain,
char **nameservers);
-extern void netcfg_write_common (u_int32_t ipaddress, char *domain,
+extern void netcfg_write_common (const char *prebaseconfig,
+ u_int32_t ipaddress, char *domain,
char *hostname, u_int32_t nameservers[]);
void netcfg_nameservers_to_array(char *nameservers, u_int32_t array[]);
Reply to: