Blame SOURCES/0045-inspection-Allow-etc-favicon.png-to-be-a-symbolic-li.patch

0d20ef
From 9b73cc026b38e871ffd13892c6e9fe878ae47b07 Mon Sep 17 00:00:00 2001
0d20ef
From: "Richard W.M. Jones" <rjones@redhat.com>
0d20ef
Date: Mon, 17 Nov 2014 10:33:35 +0000
0d20ef
Subject: [PATCH] inspection: Allow /etc/favicon.png to be a symbolic link
0d20ef
 (RHBZ#1164619).
0d20ef
0d20ef
If /etc/favicon.png is a symbolic link, follow it.
0d20ef
0d20ef
Unfortunately RHEL 7 and Fedora have crappy 16x16 /etc/favicon.png
0d20ef
symlinks in the base distro.  It would be nice to ignore this symlink,
0d20ef
but it's almost impossible to determine if the symlink is part of the
0d20ef
base distro or was added by the user.  (This is a bug in those
0d20ef
distros.)  virt-inspector and virt-mananger both ignore favicons.
0d20ef
0d20ef
(cherry picked from commit 42391913287d935e582b0c67571a17e657aa8e2e)
0d20ef
---
0d20ef
 inspector/inspector.c |  4 +++-
0d20ef
 src/inspect-icon.c    | 12 ++++++++++--
0d20ef
 2 files changed, 13 insertions(+), 3 deletions(-)
0d20ef
0d20ef
diff --git a/inspector/inspector.c b/inspector/inspector.c
0d20ef
index 8b2e578..71795ce 100644
0d20ef
--- a/inspector/inspector.c
0d20ef
+++ b/inspector/inspector.c
0d20ef
@@ -480,7 +480,9 @@ output_root (xmlTextWriterPtr xo, char *root)
0d20ef
 
0d20ef
   output_applications (xo, root);
0d20ef
 
0d20ef
-  /* Don't return favicon.  XXX Should we? */
0d20ef
+  /* Don't return favicon.  RHEL 7 and Fedora have crappy 16x16
0d20ef
+   * favicons in the base distro.
0d20ef
+   */
0d20ef
   str = guestfs_inspect_get_icon (g, root, &size,
0d20ef
                                   GUESTFS_INSPECT_GET_ICON_FAVICON, 0,
0d20ef
                                   -1);
0d20ef
diff --git a/src/inspect-icon.c b/src/inspect-icon.c
0d20ef
index 4f10dfb..72d4bba 100644
0d20ef
--- a/src/inspect-icon.c
0d20ef
+++ b/src/inspect-icon.c
0d20ef
@@ -223,6 +223,7 @@ get_png (guestfs_h *g, struct inspect_fs *fs, const char *filename,
0d20ef
          size_t *size_r, size_t max_size)
0d20ef
 {
0d20ef
   char *ret;
0d20ef
+  CLEANUP_FREE char *real = NULL;
0d20ef
   CLEANUP_FREE char *type = NULL;
0d20ef
   CLEANUP_FREE char *local = NULL;
0d20ef
   int r, w, h;
0d20ef
@@ -234,8 +235,15 @@ get_png (guestfs_h *g, struct inspect_fs *fs, const char *filename,
0d20ef
   if (r == 0)
0d20ef
     return NOT_FOUND;
0d20ef
 
0d20ef
+  /* Resolve the path, in case it's a symbolic link (as in RHEL 7). */
0d20ef
+  guestfs_push_error_handler (g, NULL, NULL);
0d20ef
+  real = guestfs_realpath (g, filename);
0d20ef
+  guestfs_pop_error_handler (g);
0d20ef
+  if (real == NULL)
0d20ef
+    return NOT_FOUND; /* could just be a broken link */
0d20ef
+
0d20ef
   /* Check the file type and geometry. */
0d20ef
-  type = guestfs_file (g, filename);
0d20ef
+  type = guestfs_file (g, real);
0d20ef
   if (!type)
0d20ef
     return NOT_FOUND;
0d20ef
 
0d20ef
@@ -252,7 +260,7 @@ get_png (guestfs_h *g, struct inspect_fs *fs, const char *filename,
0d20ef
   if (max_size == 0)
0d20ef
     max_size = 4 * w * h;
0d20ef
 
0d20ef
-  local = guestfs___download_to_tmp (g, fs, filename, "icon", max_size);
0d20ef
+  local = guestfs___download_to_tmp (g, fs, real, "icon", max_size);
0d20ef
   if (!local)
0d20ef
     return NOT_FOUND;
0d20ef
 
0d20ef
-- 
0d20ef
1.8.3.1
0d20ef