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

[d-i][patch] patch against netcfg



Hi,
I did a patch against netcfg.
It does :
- compile against libdebian-installer (I didn't add a dependancie against
it. And you must remove utils.*)
- correct some errors

I remove some '\0' affectations (?), because di_snprintfcat adds it.

And maybe, there is a error in getting interface, see bug #149579 against
net-tools (maybe you should add a comment which tells that it comes from
net-tools version xxx).
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=149579&repeatmerged=yes

Patch attached.

Thanks.

-- 
Thomas Poindessous
thomas@poindessous.com


Index: tools/netcfg/Makefile
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/netcfg/Makefile,v
retrieving revision 1.15
diff -u -r1.15 Makefile
--- tools/netcfg/Makefile	2001/02/15 05:22:11	1.15
+++ tools/netcfg/Makefile	2002/06/25 17:21:44
@@ -2,7 +2,7 @@
 TARGETS=netcfg-dhcp netcfg-static
 endif
 
-LDOPTS=-ldebconf 
+LDOPTS=-ldebconf -ldebian-installer
 PREFIX=$(DESTDIR)/usr/
 CFLAGS=-Wall  -Os
 
@@ -18,8 +18,8 @@
 
 all: $(TARGETS)
 
-netcfg-dhcp netcfg-static: netcfg-dhcp.c utils.o netcfg.o
-	$(CC) $(CFLAGS) $@.c  -o $@ $(INCS) $(LDOPTS) utils.o netcfg.o
+netcfg-dhcp netcfg-static: netcfg-dhcp.c netcfg.o
+	$(CC) $(CFLAGS) $@.c  -o $@ $(INCS) $(LDOPTS) netcfg.o
 	$(STRIP) $@
 	size $@ 
 
Index: tools/netcfg/netcfg-dhcp.c
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/netcfg/netcfg-dhcp.c,v
retrieving revision 1.13
diff -u -r1.13 netcfg-dhcp.c
--- tools/netcfg/netcfg-dhcp.c	2002/05/08 06:53:07	1.13
+++ tools/netcfg/netcfg-dhcp.c	2002/06/25 17:21:44
@@ -31,7 +31,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <cdebconf/debconfclient.h>
-#include "utils.h"
+#include <debian-installer.h>
 #include "netcfg.h"
 
 static char *interface = NULL;
@@ -65,8 +65,10 @@
 static void
 netcfg_get_dhcp ()
 {
-  if (dhcp_hostname)
+  if (dhcp_hostname) {
     free (dhcp_hostname);
+    dhcp_hostname = NULL;
+  }
 
   client->command (client, "input", "high", "netcfg/dhcp_hostname", NULL);
   client->command (client, "go", NULL);
@@ -103,14 +105,14 @@
 netcfg_activate_dhcp ()
 {
   char buf[128];
-  execlog ("/sbin/ifconfig lo 127.0.0.1");
+  di_execlog ("/sbin/ifconfig lo 127.0.0.1");
 
   switch (dhcp_client)
     {
       case PUMP:
 	snprintf (buf, sizeof (buf), "/sbin/pump -i %s", interface);
 	if (dhcp_hostname)
-	  snprintfcat (buf, sizeof (buf), " -h %s", dhcp_hostname);
+	  di_snprintfcat (buf, sizeof (buf), " -h %s", dhcp_hostname);
 	break;
 
       case DHCLIENT:
@@ -120,11 +122,11 @@
       case UDHCPC:
 	snprintf (buf, sizeof (buf), "/sbin/udhcpc -i %s -n", interface);
 	if (dhcp_hostname)
-	  snprintfcat (buf, sizeof (buf), " -H %s", dhcp_hostname);
+	  di_snprintfcat (buf, sizeof (buf), " -H %s", dhcp_hostname);
 	break;
     }
 
-  if (execlog (buf))
+  if (di_execlog (buf))
     netcfg_die (client);
 }
 
Index: tools/netcfg/netcfg-static.c
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/netcfg/netcfg-static.c,v
retrieving revision 1.13
diff -u -r1.13 netcfg-static.c
--- tools/netcfg/netcfg-static.c	2002/05/08 06:53:07	1.13
+++ tools/netcfg/netcfg-static.c	2002/06/25 17:21:44
@@ -30,7 +30,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <cdebconf/debconfclient.h>
-#include "utils.h"
+#include <debian-installer.h>
 #include "netcfg.h"
 
 
@@ -153,41 +153,39 @@
 netcfg_activate_static ()
 {
   int rv = 0;
-  char buf[128];
+  char buf[150];
 #ifdef __GNU__
 /* I had to do something like this ? */
-/*  execlog ("settrans /servers/socket/2 -fg");  */
-  execlog ("settrans /servers/socket/2 --goaway");
+/*  di_execlog ("settrans /servers/socket/2 -fg");  */
+  di_execlog ("settrans /servers/socket/2 --goaway");
   snprintf (buf, sizeof (buf),
 	    "settrans -fg /servers/socket/2 /hurd/pfinet --interface=%s --address=%s",
 	    interface, num2dot (ipaddress));
-  snprintfcat (buf, sizeof (buf) " --netmask=%s", num2dot (netmask));
-  buf[sizeof (buf) - 1] = '\0';
+  di_snprintfcat (buf, sizeof (buf), " --netmask=%s", num2dot (netmask));
 
   if (gateway)
     snprintf (buf, sizeof (buf), " --gateway=%s", num2dot (gateway));
 
-  rv |= execlog (buf);
+  rv |= di_execlog (buf);
 
 #else
-  execlog ("/sbin/ifconfig lo 127.0.0.1");
+  di_execlog ("/sbin/ifconfig lo 127.0.0.1");
 
   snprintf (buf, sizeof (buf), "/sbin/ifconfig %s %s", 
 	    interface, num2dot (ipaddress));
-  snprintfcat (buf, sizeof (buf), " netmask %s", num2dot (netmask));
-  snprintfcat (buf, sizeof (buf), " broadcast %s", num2dot (broadcast));
-  buf[sizeof (buf) - 1] = '\0';
+  di_snprintfcat (buf, sizeof (buf), " netmask %s", num2dot (netmask));
+  di_snprintfcat (buf, sizeof (buf), " broadcast %s", num2dot (broadcast));
 
   if (pointopoint)
-    snprintfcat (buf, sizeof (buf), " pointopoint %s", num2dot (pointopoint));
+    di_snprintfcat (buf, sizeof (buf), " pointopoint %s", num2dot (pointopoint));
 
-  rv |= execlog (buf);
+  rv |= di_execlog (buf);
 
   if (gateway)
     {
       snprintf (buf, sizeof (buf), "/sbin/route add default gateway %s",
 		num2dot (gateway));
-      rv |= execlog (buf);
+      rv |= di_execlog (buf);
     }
 #endif
 
Index: tools/netcfg/netcfg.c
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/netcfg/netcfg.c,v
retrieving revision 1.25
diff -u -r1.25 netcfg.c
--- tools/netcfg/netcfg.c	2002/05/08 06:53:07	1.25
+++ tools/netcfg/netcfg.c	2002/06/25 17:21:44
@@ -31,7 +31,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <cdebconf/debconfclient.h>
-#include "utils.h"
+#include <debian-installer.h>
 #include "netcfg.h"
 
 
@@ -279,7 +279,7 @@
 netcfg_get_interface (struct debconfclient *client, char **interface)
 {
   char *inter;
-  int len;
+  unsigned int len;
   int newchars;
   char *ptr;
   int num_interfaces = 0;
@@ -306,7 +306,7 @@
 	  len += newchars + 128;
 	}
 
-      snprintfcat (ptr, len, "%s: %s, ", inter, get_ifdsc (inter));
+      di_snprintfcat (ptr, len, "%s: %s, ", inter, get_ifdsc (inter));
       num_interfaces++;
     }
   getif_end ();

Reply to: