Control: tags -1 pending
Control: tags 697332 pending
Control: tags 792126 pending
Control: tags 813671 pending

Hi,

I have uploaded the attached NMU to DELAYED/5 which fixes this bug, the
other 3 bugs reported against mbr, and the associated bugs in Ubuntu.
Please tell me if I should cancel it or delay it longer.

#697332 (FTBFS on m68k, mips64el)
I have used a modified version of the patch posted in this bug report.
The original patch invokes undefined behavior on 64-bit platforms
(reading an int like it was 64-bits wide) so I have modified it slightly
to fix that.

#725417 (this bug)
I have used Lennart's patch to fix this (while not the best solution, it
is better than nothing).

#792126 (VM86 is not supported)
I have disabled the testsuite on all arches. VM86 is no longer supported
on i386 linux.

#813671 (Reading UTC/LOCAL value from wrong file)
I have used the patch already applied in Ubuntu to fix this.

Thanks,
James
diff -u mbr-1.1.11/Makefile.in mbr-1.1.11/Makefile.in
--- mbr-1.1.11/Makefile.in
+++ mbr-1.1.11/Makefile.in
@@ -815,7 +815,7 @@
        $(AS86) -0 -b $@.tmp -s $*.sym -l $*.lst $< && mv $@.tmp $@
 
 %.o: %.b
-       $(LD) -r -b binary -o $@ $<
+       xxd -i $< | $(CC) -c -x c - -o $@
 
 %.o86: %.s86
        $(AS86) -0 -w -u -o $@.tmp -l $*.lst $< && mv $@.tmp $@
diff -u mbr-1.1.11/Makefile.am mbr-1.1.11/Makefile.am
--- mbr-1.1.11/Makefile.am
+++ mbr-1.1.11/Makefile.am
@@ -68,7 +68,7 @@
        $(AS86) -0 -b $@.tmp -s $*.sym -l $*.lst $< && mv $@.tmp $@
 
 %.o: %.b
-       $(LD) -r -b binary -o $@ $<
+       xxd -i $< | $(CC) -c -x c - -o $@
 
 %.o86: %.s86
        $(AS86) -0 -w -u -o $@.tmp -l $*.lst $< && mv $@.tmp $@
diff -u mbr-1.1.11/install-mbr.c mbr-1.1.11/install-mbr.c
--- mbr-1.1.11/install-mbr.c
+++ mbr-1.1.11/install-mbr.c
@@ -829,6 +829,26 @@
     exit(1);
   }
 
+  /* Check for modern MBR format (which install-mbr does NOT currently support)
+     If bytes 445 and 446 are either 0x0000 or 0x5A5A and bytes 440-443
+     are non zero, then it is very likely to be a modern MBR and we should
+     NOT overwrite it since that would break Windows Vista and higher. */
+  if ((dp->flags & DFLAG_FORCE) == 0 &&
+      (mbr_in[CODE_SIZE-6] != 0x00 ||
+       mbr_in[CODE_SIZE-5] != 0x00 ||
+       mbr_in[CODE_SIZE-4] != 0x00 ||
+       mbr_in[CODE_SIZE-3] != 0x00) &&
+     ((mbr_in[CODE_SIZE-2] == 0x00 && mbr_in[CODE_SIZE-1] == 0x00) ||
+      (mbr_in[CODE_SIZE-2] == 0x5A && mbr_in[CODE_SIZE-1] == 0x5A)))
+  {
+    fprintf(stderr, "%s:%s: Probable detection of modern MBR format which is "
+            "currently incompatible with install-mbr.  Installing will 
probably "
+            "break Windows installations on this system.  "
+           "Use --force to override.\n", prog_name,
+           dp->target.path);
+    exit(1);
+  }
+
   /* Try to extract the parameters unless we're resetting them.  If we
      are resetting, or the extraction fails, reset them anyway. */
   if ((dp->flags & DFLAG_RESET) != 0 ||
@@ -1224,39 +1244,30 @@
       if (!optarg)
       {
        /* Try to determine the which timezone the RTC is set to. */
-       FILE *debdef=fopen("/etc/default/rcS", "r");
+       FILE *adjtime=fopen("/etc/adjtime", "r");
        /* Default to UTC */
        optarg="u";
-       if(debdef == NULL)
+       if(adjtime == NULL)
        {
          if (errno!=ENOENT)
          {
-           perror("Could not open /etc/default/rcS");
+           perror("Could not open /etc/adjtime");
            exit(1);
          }
        }
        else
        {
-         char line[8];
-         int c;
-         while (fgets(line, 8, debdef))
-         {
-           if (!memcmp("UTC=no\n", line, 7)) {
-             optarg="l";
-             break;
-           }
-           if (strchr(line, '\n') == NULL)
-           {
-             do { c = getc(debdef); } while (c != EOF && c != '\n');
-             if (c == EOF)
-               break;
-           }
-         }
-         if (ferror (debdef) || fclose(debdef))
+         char buffer[1024];
+         size_t r;
+         r = fread(buffer, 1, sizeof(buffer), adjtime);
+         if (ferror (adjtime) || fclose(adjtime))
          {
-           perror("Error reading /etc/default/rcS");
+           perror("Error reading /etc/adjtime");
            exit(1);
          }
+         buffer[r] = '\0'; /* ensure it's terminated */
+         if (strstr(buffer, "LOCAL"))
+           optarg="l";
        }
       }
       if (!strcmp(optarg, "-") ||
diff -u mbr-1.1.11/debian/changelog mbr-1.1.11/debian/changelog
--- mbr-1.1.11/debian/changelog
+++ mbr-1.1.11/debian/changelog
@@ -1,3 +1,22 @@
+mbr (1.1.11-5.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Disable testsuite on all archs. (Closes: #792126, LP: #445643)
+
+  [ Dejan Latinovic ]
+  * Fix FTBFS on ia64, m68k and mips64el by using xxd instead of ld.
+    (Closes: #697332)
+
+  [ Lannart Sorensen ]
+  * Prevent install-mbr from wiping new style MBRs.
+    (Closes: #725417, LP: #814956)
+
+  [ Martin Pitt ]
+  * Read UTC setting from /etc/adjtime instead of /etc/default/rcS.
+    (Closes: #813671)
+
+ -- James Cowgill <jcowg...@debian.org>  Fri, 21 Oct 2016 10:57:33 +0100
+
 mbr (1.1.11-5) unstable; urgency=low
 
   * Add dh_md5sums to debian/rules, thanks to jmccrohan. Closes: #672321.
diff -u mbr-1.1.11/debian/control mbr-1.1.11/debian/control
--- mbr-1.1.11/debian/control
+++ mbr-1.1.11/debian/control
@@ -3,7 +3,7 @@
 Priority: optional
 Maintainer: Santiago Garcia Mantinan <ma...@debian.org>
 Standards-Version: 3.9.3
-Build-Depends: debhelper(>= 7), bin86, util-linux (>= 2.13) | linux32
+Build-Depends: debhelper(>= 7), bin86, util-linux (>= 2.13) | linux32, xxd
 
 Package: mbr
 Architecture: any
diff -u mbr-1.1.11/debian/rules mbr-1.1.11/debian/rules
--- mbr-1.1.11/debian/rules
+++ mbr-1.1.11/debian/rules
@@ -1,7 +1,5 @@
 #!/usr/bin/make -f
 
-KERNEL_ARCH := $(shell linux64 uname -m)
-
 CC := gcc -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
 
 CFLAGS := -g -Wall -W
@@ -23,13 +21,6 @@
 build-stamp:
        ./configure --exec-prefix=`pwd`/debian/mbr/ 
--prefix=`pwd`/debian/mbr/usr
        $(MAKE) CC="$(CC)" LD="$(LD)" CFLAGS="$(CFLAGS)"
-ifneq (,$(findstring x86_64,$(KERNEL_ARCH)))
-       # Limit the tests on x86_64 kernels
-else ifeq (i386,$(DEB_BUILD_ARCH))
-       $(MAKE) check
-else
-       # Limit the tests on non i386
-endif
        touch build
 
 clean:
only in patch2:
unchanged:
--- mbr-1.1.11.orig/mbr.h
+++ mbr-1.1.11/mbr.h
@@ -4,19 +4,20 @@
 /* This file defines the interface to the encapsulated binary file
    produced by ld. */
 
-extern u_int8_t _binary_mbr_b_start[];
-extern u_int8_t _binary_mbr_b_end[];
+extern unsigned char mbr_b[];
+extern unsigned int mbr_b_len;
+
+#define MBR_START mbr_b
+#define MBR_END (mbr_b + mbr_b_len)
+#define MBR_SIZE mbr_b_len
+
+extern unsigned char y2k_b[];
+extern unsigned int y2k_b_len;
+
+#define Y2K_START y2k_b
+#define Y2K_END  (y2k_b + y2k_b_len)
+#define Y2K_SIZE y2k_b_len
 
-#define MBR_START _binary_mbr_b_start
-#define MBR_END _binary_mbr_b_end
-#define MBR_SIZE (_binary_mbr_b_end - _binary_mbr_b_start)
-
-extern u_int8_t _binary_y2k_b_start[];
-extern u_int8_t _binary_y2k_b_end[];
-
-#define Y2K_START _binary_y2k_b_start
-#define Y2K_END _binary_y2k_b_end
-#define Y2K_SIZE (_binary_y2k_b_end - _binary_y2k_b_start)
 
 /* This defines the format of the parameters in the MBR for versions 0
    and 1.  This structure is now frozen. */

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to