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

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