[RFC PATCH 4/6] Use cache directory from systemd

Victor Westerhuis victor@westerhu.is
Sun Mar 7 12:49:56 GMT 2021


Signed-off-by: Victor Westerhuis <victor@westerhu.is>
---
 config/debuginfod.service | 2 +-
 debuginfod/debuginfod.cxx | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/config/debuginfod.service b/config/debuginfod.service
index 6c434705..c99b5406 100644
--- a/config/debuginfod.service
+++ b/config/debuginfod.service
@@ -8,7 +8,7 @@ Type=Notify
 EnvironmentFile=/etc/sysconfig/debuginfod
 User=debuginfod
 Group=debuginfod
-#CacheDirectory=debuginfod
+CacheDirectory=debuginfod
 ExecStart=/usr/bin/debuginfod -d /var/cache/debuginfod/debuginfod.sqlite -p $DEBUGINFOD_PORT $DEBUGINFOD_VERBOSE $DEBUGINFOD_PRAGMAS $DEBUGINFOD_PATHS
 # Stopping can take a long time if scanning of large archives is in progress
 TimeoutStopSec=60
diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
index 4dece371..9542c5e2 100644
--- a/debuginfod/debuginfod.cxx
+++ b/debuginfod/debuginfod.cxx
@@ -3307,6 +3307,13 @@ main (int argc, char *argv[])
 
   /* Set computed default values. */
   db_path = string(getenv("HOME") ?: "/") + string("/.debuginfod.sqlite"); /* XDG? */
+#ifdef ENABLE_SYSTEMD
+  if (getenv("CACHE_DIRECTORY"))
+    {
+      db_path = string(getenv("CACHE_DIRECTORY")) + string("/debuginfod.sqlite");
+      setenv (DEBUGINFOD_CACHE_PATH_ENV_VAR, getenv("CACHE_DIRECTORY"), false);
+    }
+#endif
   int rc = regcomp (& file_include_regex, ".*", REG_EXTENDED|REG_NOSUB); // match everything
   if (rc != 0)
     error (EXIT_FAILURE, 0, "regcomp failure: %d", rc);
-- 
2.30.1


More information about the Elfutils-devel mailing list