[RFC,08/11] config: Look up IPA configurables in configuration file
diff mbox series

Message ID 20240326112419.503286-9-mzamazal@redhat.com
State Superseded
Headers show
Series
  • Add global configuration file
Related show

Commit Message

Milan Zamazal March 26, 2024, 11:24 a.m. UTC
The configuration snippet:

  configuration:
    ipa:
      config_paths: CONFIG:PATHS:...
      module_paths: MODULE:PATHS:...
      force_isolation: BOOL

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 src/libcamera/ipa_manager.cpp | 11 ++++++++---
 src/libcamera/ipa_proxy.cpp   |  8 ++++++--
 2 files changed, 14 insertions(+), 5 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp
index 5104b930..02a09724 100644
--- a/src/libcamera/ipa_manager.cpp
+++ b/src/libcamera/ipa_manager.cpp
@@ -129,8 +129,11 @@  IPAManager::IPAManager()
 	unsigned int ipaCount = 0;
 
 	/* User-specified paths take precedence. */
-	const char *modulePaths = utils::secure_getenv("LIBCAMERA_IPA_MODULE_PATH");
-	if (modulePaths) {
+	const auto confModulePaths =
+		GlobalConfiguration::envOption(
+			"LIBCAMERA_IPA_MODULE_PATH", "ipa.module_paths");
+	if (confModulePaths.has_value()) {
+		const char *modulePaths = confModulePaths.value().c_str();
 		for (const auto &dir : utils::split(modulePaths, ":")) {
 			if (dir.empty())
 				continue;
@@ -308,7 +311,9 @@  bool IPAManager::isSignatureValid([[maybe_unused]] IPAModule *ipa) const
 {
 #if HAVE_IPA_PUBKEY
 	char *force = utils::secure_getenv("LIBCAMERA_IPA_FORCE_ISOLATION");
-	if (force && force[0] != '\0') {
+	if ((force && force[0] != '\0') ||
+	    (!force && GlobalConfiguration::option<bool>("ipa.force_isolation")
+			       .value_or(false))) {
 		LOG(IPAManager, Debug)
 			<< "Isolation of IPA module " << ipa->path()
 			<< " forced through environment variable";
diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp
index 3f2cc6b8..368c1452 100644
--- a/src/libcamera/ipa_proxy.cpp
+++ b/src/libcamera/ipa_proxy.cpp
@@ -15,6 +15,7 @@ 
 #include <libcamera/base/log.h>
 #include <libcamera/base/utils.h>
 
+#include "libcamera/internal/global_configuration.h"
 #include "libcamera/internal/ipa_module.h"
 
 /**
@@ -104,8 +105,11 @@  std::string IPAProxy::configurationFile(const std::string &name) const
 	std::string ipaName = ipam_->info().name;
 
 	/* Check the environment variable first. */
-	const char *confPaths = utils::secure_getenv("LIBCAMERA_IPA_CONFIG_PATH");
-	if (confPaths) {
+	auto confConfPaths =
+		GlobalConfiguration::envOption(
+			"LIBCAMERA_IPA_CONFIG_PATH", "ipa.config_paths");
+	if (confConfPaths.has_value()) {
+		const char *confPaths = confConfPaths.value().c_str();
 		for (const auto &dir : utils::split(confPaths, ":")) {
 			if (dir.empty())
 				continue;