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

Bug#361872: debconf-copydb: Trashes debconf database in /target



On Thu, Jun 15, 2006 at 10:44:23PM +0200, Frans Pop wrote:
> The relevant files (hope the filenames speak for themselves) and an strace 
> are available from:
> http://people.debian.org/~fjp/d-i/debconf-copydb.tgz
> (uploaded instead of attached because of size)

I figured out the bug. If you tweak the source a bit to re-enable some
warnings that are normally hidden, you get

  Unknown localized field:
  Description-ar.utf-8
  Unknown localized field:
  Description-cs.utf-8
  (ad infinitum)

Now, cdebconf has no proper character set support; it could have (and it
shouldn't be all that hard), but I don't think one would want pulling iconv
into d-i, and I've never seen any templates _not_ in UTF-8 or ASCII, so I
guess it would be a bit pointless. However, it special-cases fields like
"Description-xx.UTF-8", so this should really have worked... until you
consider that it searches for ".UTF-8" using strstr(), which is
case-sensitive, and debconf (which wrote the template file in the first
place) writes ".utf-8".

The patch below makes cdebconf use strcasestr() instead of strstr(), which
fixes the problem for all but one template in that file, namely
ifupdown/convert-interfaces, which I believe is rather broken anyhow as it
uses UTF-8 without specifying a character set (just "Description-xx: "). (At
least it looks that way; the ordering of the fields is too different to
simply diff, but the template file seems to be about the right size.) It's
quite trivial once you know what's causing the problems:

--- cdebconf-0.102.orig/src/template.c	2005-09-21 19:07:46.000000000 +0200
+++ cdebconf-0.102/src/template.c	2006-06-19 18:12:12.000000000 +0200
@@ -354,7 +354,7 @@
                 free(orig_field);
                 return NULL;
             }
-            cp = strstr(altlang, ".UTF-8");
+            cp = strcasestr(altlang, ".UTF-8");
             if (cp + 6 == altlang + strlen(altlang) && cp != altlang + 1)
             {
                 *cp = 0;
@@ -465,7 +465,7 @@
                 free(orig_field);
                 return;
             }
-            cp = strstr(altlang, ".UTF-8");
+            cp = strcasestr(altlang, ".UTF-8");
             if (cp + 6 == altlang + strlen(altlang) && cp != altlang + 1)
             {
                 *cp = 0;
@@ -617,7 +617,7 @@
 			template_lset(t, NULL, "default", p+9);
 		else if (i18n && strstr(p, "Default-") == p && t != 0)
 		{
-			cp = strstr(p, ".UTF-8: ");
+			cp = strcasestr(p, ".UTF-8: ");
 			if (cp != NULL && cp != p+8)
 			{
 				lang = strndup(p+8, (int) (cp - p - 8));
@@ -635,7 +635,7 @@
 			template_lset(t, NULL, "choices", p+9);
 		else if (i18n && strstr(p, "Choices-") == p && t != 0)
 		{
-			cp = strstr(p, ".UTF-8: ");
+			cp = strcasestr(p, ".UTF-8: ");
 			if (cp != NULL && cp != p+8)
 			{
 				lang = strndup(p+8, (int) (cp - p - 8));
@@ -653,7 +653,7 @@
 			template_lset(t, NULL, "indices", p+9);
 		else if (i18n && strstr(p, "Indices-") == p && t != 0)
 		{
-			cp = strstr(p, ".UTF-8: ");
+			cp = strcasestr(p, ".UTF-8: ");
 			if (cp != NULL && cp != p+8)
 			{
 				lang = strndup(p+8, (int) (cp - p - 8));
@@ -696,7 +696,7 @@
 		}
 		else if (i18n && strstr(p, "Description-") == p && t != 0)
 		{
-			cp = strstr(p, ".UTF-8: ");
+			cp = strcasestr(p, ".UTF-8: ");
 			if (cp != NULL && cp != p+12)
 			{
 				lang = strndup(p+12, (int) (cp - p - 12));

Of course, one might want to teach cdebconf to use ".utf-8" everywhere
instead, but I'm not sure if it's the right fix, and it would probably
require changing a ton of udebs.

/* Steinar */
-- 
Homepage: http://www.sesse.net/



Reply to: