grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: [PATCH] Ignore EPERM when modifying kern.geom.debugflags
Date: Sat, 18 Jan 2014 16:20:33 +0100	[thread overview]
Message-ID: <52DA9BC1.1030604@gmail.com> (raw)
In-Reply-To: <20140117025505.GQ5883@riva.ucam.org>

[-- Attachment #1: Type: text/plain, Size: 1692 bytes --]

go ahead
On 17.01.2014 03:55, Colin Watson wrote:
> 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.
> ---
>  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 eb202dc..6145d07 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);
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 274 bytes --]

      reply	other threads:[~2014-01-18 15:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-17  2:55 [PATCH] Ignore EPERM when modifying kern.geom.debugflags Colin Watson
2014-01-18 15:20 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52DA9BC1.1030604@gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).