]> git.proxmox.com Git - grub2.git/commitdiff
Ignore EPERM when modifying kern.geom.debugflags on FreeBSD, fixing
authorColin Watson <cjwatson@debian.org>
Fri, 17 Jan 2014 02:57:25 +0000 (02:57 +0000)
committerColin Watson <cjwatson@debian.org>
Fri, 17 Jan 2014 10:41:37 +0000 (10:41 +0000)
tests.

debian/.git-dpm
debian/changelog
debian/patches/freebsd_debugflags_eperm.patch [new file with mode: 0644]
debian/patches/series
grub-core/osdep/freebsd/hostdisk.c

index b15ca6e564705ca4e2f7860c733197b3d2911280..40324bb5a3b3612c8e57caf46aedc7cab1a4e0fa 100644 (file)
@@ -1,6 +1,6 @@
 # see git-dpm(1) from git-dpm package
-6f81c737a6062ea9a7ec76b2fed0a9aaae898b6b
-6f81c737a6062ea9a7ec76b2fed0a9aaae898b6b
+294f355408ede2ec620d41794a10c2f98ccc47ae
+294f355408ede2ec620d41794a10c2f98ccc47ae
 e8f07821cce1bd0ab6d5622c2a42440f15f4fd71
 e8f07821cce1bd0ab6d5622c2a42440f15f4fd71
 grub2_2.02~beta2.orig.tar.xz
index 427a5c664b21ef97205cecb03bdbd26f48e6af6f..2ba39c78f2dd3d8c10c9ed81337dde0c917c3988 100644 (file)
@@ -5,6 +5,8 @@ grub2 (2.02~beta2-3) UNRELEASED; urgency=medium
   * Adjust Vcs-* fields to indicate the experimental branch.
   * Build-depend on cpio on architectures where we run the test suite, for
     tests/cpio_test.in.
+  * Ignore EPERM when modifying kern.geom.debugflags on FreeBSD, fixing
+    tests.
 
  -- Colin Watson <cjwatson@debian.org>  Thu, 16 Jan 2014 19:31:48 +0000
 
diff --git a/debian/patches/freebsd_debugflags_eperm.patch b/debian/patches/freebsd_debugflags_eperm.patch
new file mode 100644 (file)
index 0000000..033c881
--- /dev/null
@@ -0,0 +1,44 @@
+From 294f355408ede2ec620d41794a10c2f98ccc47ae Mon Sep 17 00:00:00 2001
+From: Colin Watson <cjwatson@debian.org>
+Date: Fri, 17 Jan 2014 02:55:58 +0000
+Subject: Ignore EPERM when modifying kern.geom.debugflags
+
+Many tests fail when run as a non-root user on FreeBSD.  The failures
+all amount to an inability to open files using grub_util_fd_open,
+because we cannot set the kern.geom.debugflags sysctl.  This sysctl is
+indeed important to allow us to do such things as installing GRUB to the
+MBR, but if we need to do that and can't then we will get an error
+later.  Enforcing it here is unnecessary and prevents otherwise
+perfectly reasonable operations.
+
+Forwarded: https://lists.gnu.org/archive/html/grub-devel/2014-01/msg00086.html
+Last-Update: 2014-01-17
+
+Patch-Name: freebsd_debugflags_eperm.patch
+---
+ grub-core/osdep/freebsd/hostdisk.c | 12 ++++++++++--
+ 1 file changed, 10 insertions(+), 2 deletions(-)
+
+diff --git a/grub-core/osdep/freebsd/hostdisk.c b/grub-core/osdep/freebsd/hostdisk.c
+index bd5fddb..a5b00f4 100644
+--- a/grub-core/osdep/freebsd/hostdisk.c
++++ b/grub-core/osdep/freebsd/hostdisk.c
+@@ -102,8 +102,16 @@ grub_util_fd_open (const char *os_dev, int flags)
+   if (! (sysctl_oldflags & 0x10)
+       && sysctlbyname ("kern.geom.debugflags", NULL , 0, &sysctl_flags, sysctl_size))
+     {
+-      grub_error (GRUB_ERR_BAD_DEVICE, "cannot set flags of sysctl kern.geom.debugflags");
+-      return GRUB_UTIL_FD_INVALID;
++      if (errno == EPERM)
++      /* Running as an unprivileged user; don't worry about restoring
++         flags, although if we try to write to anything interesting such
++         as the MBR then we may fail later.  */
++      sysctl_oldflags = 0x10;
++      else
++      {
++        grub_error (GRUB_ERR_BAD_DEVICE, "cannot set flags of sysctl kern.geom.debugflags");
++        return GRUB_UTIL_FD_INVALID;
++      }
+     }
+   ret = open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
index fc4443126820c93227411c2e62035ac9ed08400a..413e6e0999ddf20ba3a904b85f7370d2afe5d53d 100644 (file)
@@ -41,3 +41,4 @@ skip_gettext_strings_test.patch
 elf_bi_endian.patch
 macbless_mansection.patch
 grub-shell-no-pad.patch
+freebsd_debugflags_eperm.patch
index bd5fddb9150571ee646c66687523819859adaede..a5b00f4391096a7092e14b1a6379ade1f39b4ea4 100644 (file)
@@ -102,8 +102,16 @@ grub_util_fd_open (const char *os_dev, int flags)
   if (! (sysctl_oldflags & 0x10)
       && sysctlbyname ("kern.geom.debugflags", NULL , 0, &sysctl_flags, sysctl_size))
     {
-      grub_error (GRUB_ERR_BAD_DEVICE, "cannot set flags of sysctl kern.geom.debugflags");
-      return GRUB_UTIL_FD_INVALID;
+      if (errno == EPERM)
+       /* Running as an unprivileged user; don't worry about restoring
+          flags, although if we try to write to anything interesting such
+          as the MBR then we may fail later.  */
+       sysctl_oldflags = 0x10;
+      else
+       {
+         grub_error (GRUB_ERR_BAD_DEVICE, "cannot set flags of sysctl kern.geom.debugflags");
+         return GRUB_UTIL_FD_INVALID;
+       }
     }
 
   ret = open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);