manager: allow running at non-standard path
Add an optional argument to the daemon to allow the persistent
location to be a non-standard path. This enables running the
application as a normal user on a developer system rather than
requiring it to be installed in a full BMC image.
Tested:
Ran with `biosconfig-manager /tmp/bios-config-manager`:
```
$ busctl --user tree xyz.openbmc_project.BIOSConfigManager
└─ /xyz
└─ /xyz/openbmc_project
└─ /xyz/openbmc_project/bios_config
├─ /xyz/openbmc_project/bios_config/manager
└─ /xyz/openbmc_project/bios_config/password
```
Change-Id: I42f688e233060c43983d2690facbb1026e678c77
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/include/password.hpp b/include/password.hpp
index 2b320a5..4b2d788 100644
--- a/include/password.hpp
+++ b/include/password.hpp
@@ -59,7 +59,8 @@
* @param[in] systemBus - bus connection
*/
Password(sdbusplus::asio::object_server& objectServer,
- std::shared_ptr<sdbusplus::asio::connection>& systemBus);
+ std::shared_ptr<sdbusplus::asio::connection>& systemBus,
+ std::string persistPath);
/** @brief Set the BIOS attribute with a new value, the new value is added
* to the PendingAttribute.
diff --git a/src/main.cpp b/src/main.cpp
index 8c2d78b..1e960ae 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -24,8 +24,17 @@
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
-int main()
+PHOSPHOR_LOG2_USING;
+
+int main(int argc, char** argv)
{
+ std::string persistPath = BIOS_PERSIST_PATH;
+ if (argc >= 2)
+ {
+ persistPath = argv[1];
+ info("Using temporary path {PATH}", "PATH", persistPath);
+ }
+
boost::asio::io_service io;
auto systemBus = std::make_shared<sdbusplus::asio::connection>(io);
@@ -39,7 +48,7 @@
* Object path : /xyz/openbmc_project/bios_config/manager
* Interface : xyz.openbmc_project.BIOSConfig.Manager
*/
- bios_config::Manager manager(objectServer, systemBus, BIOS_PERSIST_PATH);
+ bios_config::Manager manager(objectServer, systemBus, persistPath);
/**
* Password class is responsible for handling methods and signals under
@@ -48,7 +57,7 @@
* Object path : /xyz/openbmc_project/bios_config/password
* Interface : xyz.openbmc_project.BIOSConfig.Password
*/
- bios_config_pwd::Password password(objectServer, systemBus);
+ bios_config_pwd::Password password(objectServer, systemBus, persistPath);
io.run();
return 0;
diff --git a/src/password.cpp b/src/password.cpp
index 03aeb79..6503e53 100644
--- a/src/password.cpp
+++ b/src/password.cpp
@@ -15,7 +15,6 @@
*/
#include "password.hpp"
-#include "config.hpp"
#include "xyz/openbmc_project/BIOSConfig/Common/error.hpp"
#include "xyz/openbmc_project/Common/error.hpp"
@@ -235,7 +234,8 @@
}
}
Password::Password(sdbusplus::asio::object_server& objectServer,
- std::shared_ptr<sdbusplus::asio::connection>& systemBus) :
+ std::shared_ptr<sdbusplus::asio::connection>& systemBus,
+ std::string persistPath) :
sdbusplus::xyz::openbmc_project::BIOSConfig::server::Password(
*systemBus, objectPathPwd),
objServer(objectServer), systemBus(systemBus)
@@ -243,7 +243,7 @@
lg2::debug("BIOS config password is running");
try
{
- fs::path biosDir(BIOS_PERSIST_PATH);
+ fs::path biosDir(persistPath);
fs::create_directories(biosDir);
seedFile = biosDir / biosSeedFile;
}