From 653e374ef6a5fda3e6575166e159d5727b9248fa Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 16 May 2016 07:22:20 -0400 Subject: [PATCH] inspection: Unquote UUID=.. or LABEL=.. before passing to findfs (RHBZ#1335671). In /etc/fstab the UUID= or LABEL= field may be quoted. Augeas returns the field including the quotes, and we passed this directly to guestfs_findfs_uuid or guestfs_findfs_label. It happens that this works on upstream findfs, although it doesn't work in RHEL 7.2. The correct thing to do is to remove the quotes before passing the UUID or label to these functions. Thanks: Thom Carlin for reporting the bug, Karel Zak for identifying the change in behaviour in util-linux. --- src/inspect-fs-unix.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c index dab43701c..82d249ae2 100644 --- a/src/inspect-fs-unix.c +++ b/src/inspect-fs-unix.c @@ -1343,10 +1343,16 @@ check_fstab (guestfs_h *g, struct inspect_fs *fs) continue; /* Resolve UUID= and LABEL= to the actual device. */ - if (STRPREFIX (spec, "UUID=")) - mountable = guestfs_findfs_uuid (g, &spec[5]); - else if (STRPREFIX (spec, "LABEL=")) - mountable = guestfs_findfs_label (g, &spec[6]); + if (STRPREFIX (spec, "UUID=")) { + CLEANUP_FREE char *s = guestfs_int_shell_unquote (&spec[5]); + if (s == NULL) { perrorf (g, "guestfs_int_shell_unquote"); return -1; } + mountable = guestfs_findfs_uuid (g, s); + } + else if (STRPREFIX (spec, "LABEL=")) { + CLEANUP_FREE char *s = guestfs_int_shell_unquote (&spec[6]); + if (s == NULL) { perrorf (g, "guestfs_int_shell_unquote"); return -1; } + mountable = guestfs_findfs_label (g, s); + } /* Ignore "/.swap" (Pardus) and pseudo-devices like "tmpfs". */ else if (STREQ (spec, "/dev/root") || (is_bsd && STREQ (mp, "/"))) /* Resolve /dev/root to the current device.