From 1c4d3d34af613ad511b779eb7375562486bb2758 Mon Sep 17 00:00:00 2001 From: Benjamin Fair Date: Fri, 19 Oct 2018 17:22:53 -0700 Subject: main: catch exceptions when loading blob handlers If an error occurs while attempting to load the blob handlers (such as a filesystem error), the uncaught exception will crash the entire IPMI daemon. Instead, catch the exception and print an error message. Tested: ipmid doesn't crash when /usr/lib/blobs-ipmid is missing Signed-off-by: Benjamin Fair Change-Id: Ic316f6e5aa3c4bc6eba4fa2e561b338f4b20f606 --- main.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index c6b5b04..e680d7c 100644 --- a/main.cpp +++ b/main.cpp @@ -26,6 +26,7 @@ #include #include #include +#include /* TODO: Swap out once https://gerrit.openbmc-project.xyz/12743 is merged */ namespace oem @@ -36,6 +37,8 @@ constexpr auto blobTransferCmd = 128; namespace blobs { +using namespace phosphor::logging; + static ipmi_ret_t handleBlobCommand(ipmi_cmd_t cmd, const uint8_t* reqBuf, uint8_t* replyCmdBuf, size_t* dataLen) { @@ -75,6 +78,14 @@ void setupBlobGlobalHandler() handleBlobCommand); /* Install handlers. */ - loadLibraries(expectedHandlerPath); + try + { + loadLibraries(expectedHandlerPath); + } + catch (const std::exception& e) + { + log("ERROR loading blob handlers", + entry("ERROR=%s", e.what())); + } } } // namespace blobs -- cgit v1.2.3