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

Bug#255187: Please add resolvconf support



Package: netcfg
Version: 0.70
Severity: wishlist

It would be helpful to the user who wants to install resolvconf if the
static nameserver information that netcfg writes directly to
/etc/resolv.conf were also written to /etc/network/interfaces in the
format required for it to get included in the dynamic resolvconf-generated
resolv.conf file.

I believe that it is safe to enhance netcfg in this way; the additional
options in /etc/network/interfaces have no effect so long as resolvconf
is not installed.

Here is a patch which, although untested, should provide a clear idea of
what I'm suggesting.  In creating this patch I have assumed that netcfg
only writes a single interface definition to /e/n/i and I have assumed
that the /e/n/i written by netcfg doesn't get overwritten later in the
installation process.  This patch includes the patch I submitted in
#255185 which replaces underscores with hyphens in wireless-* option
names.  I have also added a few comments.

--- netcfg-0.70_ORIG/static.c	2004-06-15 06:41:03.000000000 +0200
+++ netcfg-0.70/static.c	2004-06-19 13:38:44.000000000 +0200
@@ -259,14 +259,36 @@
             fprintf(fp, "\tgateway %s\n", inet_ntop (AF_INET, &gateway, ptr1, sizeof (ptr1)));
         if (pointopoint.s_addr)
             fprintf(fp, "\tpointopoint %s\n", inet_ntop (AF_INET, &pointopoint, ptr1, sizeof (ptr1)));
+	/*
+	 * Write wireless-tools options
+	 */
 	if (is_wireless_iface(interface))
 	{
-	  fprintf(fp, "\twireless_mode %s\n",
+	  fprintf(fp, "\t# The wireless-* options are used by the wireless-tools package\n");
+	  fprintf(fp, "\twireless-mode %s\n",
 	      (mode == MANAGED) ? "managed" : "ad-hoc");
-	  fprintf(fp, "\twireless_essid %s\n", essid ? essid : "any");
+	  fprintf(fp, "\twireless-essid %s\n", essid ? essid : "any");
 
 	  if (wepkey != NULL)
-	    fprintf(fp, "\twireless_key %s\n", wepkey);
+	    fprintf(fp, "\twireless-key %s\n", wepkey);
+	}
+	/*
+	 * Write resolvconf options
+	 * This code should be kept in sync with the code below that
+	 * writes the /etc/resolv.conf file
+	 */
+	if (nameservers[0].s_addr || (domain && !empty_str(domain))) {
+        	int i = 0;
+		fprintf(fp, "\t# The dns-* options are used by the resolvconf package, if installed\n");
+		if (domain && !empty_str(domain))
+			fprintf(fp, "\tdns-search %s\n", domain);
+		if (nameservers[0].s_addr) {
+			fprintf(fp, "\tdns-nameservers");
+			while (nameservers[i].s_addr)
+				fprintf(fp, " %s",
+					inet_ntop (AF_INET, &nameservers[i++], ptr1, sizeof (ptr1)));
+			fprintf(fp, "\n");
+		}
 	}
         fclose(fp);
     } else


-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (900, 'unstable'), (700, 'testing'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.7
Locale: LANG=en_IE@euro, LC_CTYPE=en_IE@euro



Reply to: