|
|
f731ee |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
f731ee |
From: Colin Watson <cjwatson@ubuntu.com>
|
|
|
f731ee |
Date: Fri, 17 Jan 2014 02:28:46 +0000
|
|
|
f731ee |
Subject: [PATCH] Ignore EPERM when modifying kern.geom.debugflags
|
|
|
f731ee |
|
|
|
f731ee |
Many tests fail when run as a non-root user on FreeBSD. The failures
|
|
|
f731ee |
all amount to an inability to open files using grub_util_fd_open,
|
|
|
f731ee |
because we cannot set the kern.geom.debugflags sysctl. This sysctl is
|
|
|
f731ee |
indeed important to allow us to do such things as installing GRUB to the
|
|
|
f731ee |
MBR, but if we need to do that and can't then we will get an error
|
|
|
f731ee |
later. Enforcing it here is unnecessary and prevents otherwise
|
|
|
f731ee |
perfectly reasonable operations.
|
|
|
f731ee |
---
|
|
|
f731ee |
grub-core/osdep/freebsd/hostdisk.c | 12 ++++++++++--
|
|
|
f731ee |
ChangeLog | 7 +++++++
|
|
|
f731ee |
2 files changed, 17 insertions(+), 2 deletions(-)
|
|
|
f731ee |
|
|
|
f731ee |
diff --git a/grub-core/osdep/freebsd/hostdisk.c b/grub-core/osdep/freebsd/hostdisk.c
|
|
|
f731ee |
index eb202dcc831..6145d073555 100644
|
|
|
f731ee |
--- a/grub-core/osdep/freebsd/hostdisk.c
|
|
|
f731ee |
+++ b/grub-core/osdep/freebsd/hostdisk.c
|
|
|
f731ee |
@@ -102,8 +102,16 @@ grub_util_fd_open (const char *os_dev, int flags)
|
|
|
f731ee |
if (! (sysctl_oldflags & 0x10)
|
|
|
f731ee |
&& sysctlbyname ("kern.geom.debugflags", NULL , 0, &sysctl_flags, sysctl_size))
|
|
|
f731ee |
{
|
|
|
f731ee |
- grub_error (GRUB_ERR_BAD_DEVICE, "cannot set flags of sysctl kern.geom.debugflags");
|
|
|
f731ee |
- return GRUB_UTIL_FD_INVALID;
|
|
|
f731ee |
+ if (errno == EPERM)
|
|
|
f731ee |
+ /* Running as an unprivileged user; don't worry about restoring
|
|
|
f731ee |
+ flags, although if we try to write to anything interesting such
|
|
|
f731ee |
+ as the MBR then we may fail later. */
|
|
|
f731ee |
+ sysctl_oldflags = 0x10;
|
|
|
f731ee |
+ else
|
|
|
f731ee |
+ {
|
|
|
f731ee |
+ grub_error (GRUB_ERR_BAD_DEVICE, "cannot set flags of sysctl kern.geom.debugflags");
|
|
|
f731ee |
+ return GRUB_UTIL_FD_INVALID;
|
|
|
f731ee |
+ }
|
|
|
f731ee |
}
|
|
|
f731ee |
|
|
|
f731ee |
ret = open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
|
|
|
f731ee |
diff --git a/ChangeLog b/ChangeLog
|
|
|
f731ee |
index 4688ff4e6d3..10abfe28f20 100644
|
|
|
f731ee |
--- a/ChangeLog
|
|
|
f731ee |
+++ b/ChangeLog
|
|
|
f731ee |
@@ -1,3 +1,10 @@
|
|
|
f731ee |
+2014-01-19 Colin Watson <cjwatson@ubuntu.com>
|
|
|
f731ee |
+
|
|
|
f731ee |
+ * grub-core/osdep/freebsd/hostdisk.c (grub_util_fd_open): Ignore
|
|
|
f731ee |
+ EPERM when modifying kern.geom.debugflags. It is only a problem for
|
|
|
f731ee |
+ such things as installing GRUB to the MBR, in which case there'll be
|
|
|
f731ee |
+ an error later anyway, not for opening files during tests.
|
|
|
f731ee |
+
|
|
|
f731ee |
2014-01-18 Andrey Borzenkov <arvidjaar@gmail.com>
|
|
|
f731ee |
|
|
|
f731ee |
* grub-core/Makefile.am: Build grub_emu_init.[ch] from MODULE_FILES
|