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.
This commit is contained in:
Richard W.M. Jones
2016-05-16 07:22:20 -04:00
parent e13334a1a2
commit 653e374ef6

View File

@@ -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.