]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Ignore EPERM when modifying kern.geom.debugflags
authorColin Watson <cjwatson@ubuntu.com>
Fri, 17 Jan 2014 02:28:46 +0000 (02:28 +0000)
committerColin Watson <cjwatson@ubuntu.com>
Sun, 19 Jan 2014 14:38:07 +0000 (14:38 +0000)
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.

ChangeLog
grub-core/osdep/freebsd/hostdisk.c

index 4688ff4e6d30f2d46a28f56d281d3066d90be899..10abfe28f20a249323767f4a0769b518067e220e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-01-19  Colin Watson  <cjwatson@ubuntu.com>
+
+       * grub-core/osdep/freebsd/hostdisk.c (grub_util_fd_open): Ignore
+       EPERM when modifying kern.geom.debugflags.  It is only a problem for
+       such things as installing GRUB to the MBR, in which case there'll be
+       an error later anyway, not for opening files during tests.
+
 2014-01-18  Andrey Borzenkov <arvidjaar@gmail.com>
 
        * grub-core/Makefile.am: Build grub_emu_init.[ch] from MODULE_FILES
index eb202dcc831a3bcfb23d95dcd6a122bd01e3900a..6145d073555246d714a9f3fd6af528498b641e0c 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);