summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-04-07 23:47:06 +0300
committerEd Tanous <ed@tanous.net>2024-04-11 21:21:53 +0300
commit4c521c3c34162b6a5930ac1d78da3456f9b69283 (patch)
tree9341d14061a4dd9a21d41a528a66d45c78687b74 /include
parent8c3faccc941d5b32722554f8f24f320fd02dd4ab (diff)
downloadbmcweb-4c521c3c34162b6a5930ac1d78da3456f9b69283.tar.xz
Fix file removal
This code used std::remove, which is a mechanism for removing characters from strings. Clearly it meant std::filesystem::remove(), which removes files from the filesystem. Correct it. Change-Id: I030966203c1682a11c723c596accdf34637dd1ba Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'include')
-rw-r--r--include/hostname_monitor.hpp7
-rw-r--r--include/nbd_proxy.hpp9
2 files changed, 13 insertions, 3 deletions
diff --git a/include/hostname_monitor.hpp b/include/hostname_monitor.hpp
index 6339a6b414..188deff564 100644
--- a/include/hostname_monitor.hpp
+++ b/include/hostname_monitor.hpp
@@ -28,7 +28,12 @@ inline void installCertificate(const std::filesystem::path& certPath)
BMCWEB_LOG_INFO("Replace HTTPs Certificate Success, "
"remove temporary certificate file..");
- remove(certPath.c_str());
+ std::error_code ec2;
+ std::filesystem::remove(certPath.c_str(), ec2);
+ if (ec2)
+ {
+ BMCWEB_LOG_ERROR("Failed to remove certificate");
+ }
},
"xyz.openbmc_project.Certs.Manager.Server.Https",
"/xyz/openbmc_project/certs/server/https/1",
diff --git a/include/nbd_proxy.hpp b/include/nbd_proxy.hpp
index 838e7a1d2c..9607ddfb10 100644
--- a/include/nbd_proxy.hpp
+++ b/include/nbd_proxy.hpp
@@ -63,8 +63,13 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
boost::system::error_code ec;
peerSocket.close(ec);
- BMCWEB_LOG_DEBUG("std::remove({})", socketId);
- std::remove(socketId.c_str());
+ BMCWEB_LOG_DEBUG("std::filesystem::remove({})", socketId);
+ std::error_code ec2;
+ std::filesystem::remove(socketId.c_str(), ec2);
+ if (ec2)
+ {
+ BMCWEB_LOG_DEBUG("Failed to remove file, ignoring");
+ }
crow::connections::systemBus->async_method_call(
dbus::utility::logError, "xyz.openbmc_project.VirtualMedia", path,