summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Tritz <mtritz@us.ibm.com>2017-08-14 14:33:30 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-08-18 17:28:27 +0000
commitb1cfdf99c4b9cccccb21f34150d962004dfa4fef (patch)
treed7ebafe30d08bc73c7b202ac5351a924dd5d1839
parent7b5010f2579f497ec36ae7220ed871d7ba76fc26 (diff)
downloadphosphor-bmc-code-mgmt-b1cfdf99c4b9cccccb21f34150d962004dfa4fef.tar.gz
phosphor-bmc-code-mgmt-b1cfdf99c4b9cccccb21f34150d962004dfa4fef.zip
Check if BMC tarball has all required files during image verifcation
In this commit, the image verification process upon BMC image upload is extended such that the existence of all four image files is verified. Previously, only the "image-rofs" file was checked. Resolves openbmc/openbmc#2143 Change-Id: Ieaf774ab12e41a46da53095609d00e007e01421a Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
-rw-r--r--item_updater.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/item_updater.cpp b/item_updater.cpp
index 80568fe..8bd868b 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -20,7 +20,10 @@ namespace server = sdbusplus::xyz::openbmc_project::Software::server;
using namespace phosphor::logging;
namespace fs = std::experimental::filesystem;
-constexpr auto bmcImage = "image-rofs";
+const std::vector<std::string> bmcImages = {"image-kernel",
+ "image-rofs",
+ "image-rwfs",
+ "image-u-boot"};
void ItemUpdater::createActivation(sdbusplus::message::message& msg)
{
@@ -196,20 +199,27 @@ void ItemUpdater::erase(std::string entryId)
ItemUpdater::ActivationStatus ItemUpdater::validateSquashFSImage(
const std::string& filePath)
{
+ bool invalid = false;
- fs::path file(filePath);
- file /= bmcImage;
- std::ifstream efile(file.c_str());
-
- if (efile.good() == 1)
+ for (auto& bmcImage : bmcImages)
{
- return ItemUpdater::ActivationStatus::ready;
+ fs::path file(filePath);
+ file /= bmcImage;
+ std::ifstream efile(file.c_str());
+ if (efile.good() != 1)
+ {
+ log<level::ERR>("Failed to find the BMC image.",
+ entry("IMAGE=%s", bmcImage.c_str()));
+ invalid = true;
+ }
}
- else
+
+ if (invalid)
{
- log<level::ERR>("Failed to find the BMC image.");
return ItemUpdater::ActivationStatus::invalid;
}
+
+ return ItemUpdater::ActivationStatus::ready;
}
void ItemUpdater::freePriority(uint8_t value)
OpenPOWER on IntegriCloud