Blame SOURCES/elfutils-0.178-debuginfod-no-cache.patch

ca9947
commit d8bad02afc7b7f30402b4e0e458df874a6d600da
ca9947
Author: Mark Wielaard <mark@klomp.org>
ca9947
Date:   Mon Dec 9 19:38:19 2019 +0100
ca9947
ca9947
    debuginfod: Check the DEBUGINFOD_URLS environment variable early in client.
ca9947
    
ca9947
    If the debuginfod-client isn't configured we should do as little
ca9947
    as possible. Simply return early with ENOSYS if no servers are
ca9947
    configured. This means we won't check
ca9947
    
ca9947
    This does change the behavior of the debuginfod_find calls slightly.
ca9947
    Previously we would setup and check the cache if the given build-id
ca9947
    was valid. Which might have provided a result if an earlier client
ca9947
    had run with the same cache and valid server URLs which knew about
ca9947
    that particular build-id. Now we don't return any cached results
ca9947
    unless at least one server is configured.
ca9947
    
ca9947
    This prevents selinux errors when the library is used in a confined
ca9947
    setup.
ca9947
    
ca9947
    Signed-off-by: Mark Wielaard <mark@klomp.org>
ca9947
ca9947
diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
ca9947
index 302ea2dc..ab7b4e13 100644
ca9947
--- a/debuginfod/debuginfod-client.c
ca9947
+++ b/debuginfod/debuginfod-client.c
ca9947
@@ -301,6 +301,16 @@ debuginfod_query_server (debuginfod_client *c,
ca9947
   char target_cache_tmppath[PATH_MAX*5];
ca9947
   char suffix[PATH_MAX*2];
ca9947
   char build_id_bytes[MAX_BUILD_ID_BYTES * 2 + 1];
ca9947
+  int rc;
ca9947
+
ca9947
+  /* Is there any server we can query?  If not, don't do any work,
ca9947
+     just return with ENOSYS.  Don't even access the cache.  */
ca9947
+  urls_envvar = getenv(server_urls_envvar);
ca9947
+  if (urls_envvar == NULL || urls_envvar[0] == '\0')
ca9947
+    {
ca9947
+      rc = -ENOSYS;
ca9947
+      goto out;
ca9947
+    }
ca9947
 
ca9947
   /* Copy lowercase hex representation of build_id into buf.  */
ca9947
   if ((build_id_len >= MAX_BUILD_ID_BYTES) ||
ca9947
@@ -373,7 +383,7 @@ debuginfod_query_server (debuginfod_client *c,
ca9947
   /* XXX combine these */
ca9947
   snprintf(interval_path, sizeof(interval_path), "%s/%s", cache_path, cache_clean_interval_filename);
ca9947
   snprintf(maxage_path, sizeof(maxage_path), "%s/%s", cache_path, cache_max_unused_age_filename);
ca9947
-  int rc = debuginfod_init_cache(cache_path, interval_path, maxage_path);
ca9947
+  rc = debuginfod_init_cache(cache_path, interval_path, maxage_path);
ca9947
   if (rc != 0)
ca9947
     goto out;
ca9947
   rc = debuginfod_clean_cache(c, cache_path, interval_path, maxage_path);
ca9947
@@ -390,14 +400,6 @@ debuginfod_query_server (debuginfod_client *c,
ca9947
       return fd;
ca9947
     }
ca9947
 
ca9947
-
ca9947
-  urls_envvar = getenv(server_urls_envvar);
ca9947
-  if (urls_envvar == NULL || urls_envvar[0] == '\0')
ca9947
-    {
ca9947
-      rc = -ENOSYS;
ca9947
-      goto out;
ca9947
-    }
ca9947
-
ca9947
   if (getenv(server_timeout_envvar))
ca9947
     server_timeout = atoi (getenv(server_timeout_envvar));
ca9947