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

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