]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4198] Applied proposed fix
authorFrancis Dupont <fdupont@isc.org>
Fri, 21 Nov 2025 10:34:20 +0000 (11:34 +0100)
committerFrancis Dupont <fdupont@isc.org>
Fri, 21 Nov 2025 13:11:24 +0000 (14:11 +0100)
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc

index 7de74b56cadd58d756a5d739c8e96319705fc784..40b1ed2e47577282884332a3841deb714637855c 100644 (file)
@@ -376,23 +376,13 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&,
         return (result);
     }
 
-    ConstElementPtr lease_database = dhcp4->get("lease-database");
-    if (lease_database) {
-        db::DbAccessParser parser;
-        std::string access_string;
-        parser.parse(access_string, lease_database);
-        auto params = parser.getDbAccessParameters();
-        if (params["type"] == "memfile") {
-            string file_name = params["name"];
-            if (!file_name.empty() &&
-                (file_name.find_first_of('/') == string::npos)) {
-                // Prepend the current datadir to the name.
-                file_name = CfgMgr::instance().getDataDir() + "/" + file_name;
-            }
-            if (Memfile_LeaseMgr::isLFCProcessRunning(file_name, Memfile_LeaseMgr::V4)) {
-                return (isc::config::createAnswer(CONTROL_RESULT_ERROR,
-                        "Can not update configuration while lease file cleanup process is running."));
-            }
+    if (LeaseMgrFactory::haveInstance() &&
+        (LeaseMgrFactory::instance().getType() == "memfile")) {
+        Memfile_LeaseMgr& mgr = dynamic_cast<Memfile_LeaseMgr&>(LeaseMgrFactory::instance());
+        auto file_name = mgr.getLeaseFilePath(Memfile_LeaseMgr::V4);
+        if (Memfile_LeaseMgr::isLFCProcessRunning(file_name, Memfile_LeaseMgr::V4)) {
+            return (isc::config::createAnswer(CONTROL_RESULT_ERROR,
+                    "Can not update configuration while lease file cleanup process is running."));
         }
     }
 
index 803e3fbaaeea580b6800293a6a9db9edd0479570..9452fe2a16879b370874d89be5446c15c809d4c3 100644 (file)
@@ -379,23 +379,13 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&,
         return (result);
     }
 
-    ConstElementPtr lease_database = dhcp6->get("lease-database");
-    if (lease_database) {
-        db::DbAccessParser parser;
-        std::string access_string;
-        parser.parse(access_string, lease_database);
-        auto params = parser.getDbAccessParameters();
-        if (params["type"] == "memfile") {
-            string file_name = params["name"];
-            if (!file_name.empty() &&
-                (file_name.find_first_of('/') == string::npos)) {
-                // Prepend the current datadir to the name.
-                file_name = CfgMgr::instance().getDataDir() + "/" + file_name;
-            }
-            if (Memfile_LeaseMgr::isLFCProcessRunning(file_name, Memfile_LeaseMgr::V6)) {
-                return (isc::config::createAnswer(CONTROL_RESULT_ERROR,
-                        "Can not update configuration while lease file cleanup process is running."));
-            }
+    if (LeaseMgrFactory::haveInstance() &&
+        (LeaseMgrFactory::instance().getType() == "memfile")) {
+        Memfile_LeaseMgr& mgr = dynamic_cast<Memfile_LeaseMgr&>(LeaseMgrFactory::instance());
+        auto file_name = mgr.getLeaseFilePath(Memfile_LeaseMgr::V6);
+        if (Memfile_LeaseMgr::isLFCProcessRunning(file_name, Memfile_LeaseMgr::V6)) {
+            return (isc::config::createAnswer(CONTROL_RESULT_ERROR,
+                    "Can not update configuration while lease file cleanup process is running."));
         }
     }