[PATCH v4 09/15] config: Look up IPA configurables in configuration file
Milan Zamazal
mzamazal at redhat.com
Wed Sep 25 11:58:41 CEST 2024
The configuration snippet:
configuration:
ipa:
config_paths: CONFIG:PATHS:...
module_paths: MODULE:PATHS:...
force_isolation: BOOL
Signed-off-by: Milan Zamazal <mzamazal at redhat.com>
---
src/libcamera/ipa_manager.cpp | 11 ++++++++---
src/libcamera/ipa_proxy.cpp | 16 +++++++++++-----
2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp
index 28384844a..573e39b82 100644
--- a/src/libcamera/ipa_manager.cpp
+++ b/src/libcamera/ipa_manager.cpp
@@ -123,8 +123,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;
@@ -298,7 +301,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 85004737c..787d58019 100644
--- a/src/libcamera/ipa_proxy.cpp
+++ b/src/libcamera/ipa_proxy.cpp
@@ -14,6 +14,7 @@
#include <libcamera/base/log.h>
#include <libcamera/base/utils.h>
+#include "libcamera/internal/global_configuration.h"
#include "libcamera/internal/ipa_module.h"
/**
@@ -108,8 +109,11 @@ std::string IPAProxy::configurationFile(const std::string &name,
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;
@@ -183,9 +187,11 @@ std::string IPAProxy::resolvePath(const std::string &file) const
std::string proxyFile = "/" + file;
/* Check env variable first. */
- const char *execPaths = utils::secure_getenv("LIBCAMERA_IPA_PROXY_PATH");
- if (execPaths) {
- for (const auto &dir : utils::split(execPaths, ":")) {
+ const auto execPaths =
+ GlobalConfiguration::envOption(
+ "LIBCAMERA_IPA_PROXY_PATH", "ipa.proxy_paths");
+ if (execPaths.has_value()) {
+ for (const auto &dir : utils::split(execPaths.value().c_str(), ":")) {
if (dir.empty())
continue;
--
2.44.1
More information about the libcamera-devel
mailing list