All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mario Limonciello <mario_limonciello@dell.com>
To: "grub-devel@gnu.org" <grub-devel@gnu.org>
Cc: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
Subject: [PATCH] Use realpath to clean up arguments to grub-probe
Date: Tue, 02 Aug 2011 19:54:40 -0500	[thread overview]
Message-ID: <4E389C50.3080001@dell.com> (raw)


[-- Attachment #1.1.1: Type: text/plain, Size: 399 bytes --]

Hi,

I've found that the EFI grub-install command can fail to properly figure out devices when using the --root-directory command.  This seems to be rooted from a call to grub-probe with a ".." in the path.

This is fixed by using realpath to clean up the path passed in grub-probe.  Please see the attached patch.

Thanks,

-- 
*Mario Limonciello*
Linux Engineer
*Dell*| OS Engineering

[-- Attachment #1.1.2: Type: text/html, Size: 1429 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: realpath.patch --]
[-- Type: text/x-diff; name="realpath.patch", Size: 1210 bytes --]

=== modified file 'ChangeLog'
--- ChangeLog	2011-07-26 15:19:47 +0000
+++ ChangeLog	2011-08-03 00:48:10 +0000
@@ -1,3 +1,8 @@
+2011-08-02  Mario Limonciello <mario_limonciello@dell.com>
+
+	* util/grub-probe.c: Use realpath to clean up directory arguments
+	including '..' such as that used in grub-install for EFI.
+
 2011-07-26  Colin Watson  <cjwatson@ubuntu.com>
 
 	* configure.ac: The Loongson port requires grub-mkfont due to its

=== modified file 'util/grub-probe.c'
--- util/grub-probe.c	2011-04-25 12:52:07 +0000
+++ util/grub-probe.c	2011-08-03 00:53:57 +0000
@@ -42,6 +42,9 @@
 #include <string.h>
 #include <stdlib.h>
 #include <sys/stat.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
 
 #define _GNU_SOURCE	1
 #include <getopt.h>
@@ -181,7 +184,15 @@
 #endif
     }
   else
-    device_name = grub_guess_root_device (path);
+    {
+#ifdef PATH_MAX
+      grub_path = xmalloc (PATH_MAX);
+      realpath (path, grub_path);
+#else
+      grub_path = realpath(path, NULL);
+#endif
+    device_name = grub_guess_root_device (grub_path);
+    }
 
   if (! device_name)
     grub_util_error ("cannot find a device for %s (is /dev mounted?)", path);


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

             reply	other threads:[~2011-08-03  0:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-03  0:54 Mario Limonciello [this message]
2011-08-15 22:30 ` [PATCH] Use realpath to clean up arguments to grub-probe Colin Watson

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=4E389C50.3080001@dell.com \
    --to=mario_limonciello@dell.com \
    --cc=grub-devel@gnu.org \
    --cc=phcoder@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.