[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#177666: tag 177666 patch



tag 177666 patch
thanks

This patch copies the network configuration files to the /target,
adds a loopback device to /etc/network/interfaces, and ensures
that the network interface is automatically started.

Matt

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 08:37:57.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);
@@ -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 10:15:47.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);
@@ -409,13 +409,22 @@
 
 
 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))) {
+        if ((fp = file_open(HOSTS_FILE, "w"))) {
                 fprintf(fp, "127.0.0.1\tlocalhost\n");
                 if (ipaddress) {
                         if (domain)
@@ -428,9 +437,12 @@
                 }
 
                 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 +452,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 08:38:35.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);
 
@@ -45,7 +45,8 @@
 			       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: