From: Andrei Pavel Date: Fri, 20 Jun 2025 12:36:15 +0000 (+0300) Subject: [#3907] Progressed some more with YANG modules X-Git-Tag: Kea-3.0.0~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=761c7d3e6cb1a1bd637c961c68d66e7e5c6b4200;p=thirdparty%2Fkea.git [#3907] Progressed some more with YANG modules --- diff --git a/doc/examples/kea4/all-keys-netconf.json b/doc/examples/kea4/all-keys-netconf.json index 92b09359ca..e350af1bd2 100644 --- a/doc/examples/kea4/all-keys-netconf.json +++ b/doc/examples/kea4/all-keys-netconf.json @@ -236,9 +236,7 @@ // If password is not specified an empty // password is used. - "password": "1234", - "password-file": "", - "user-file": "" + "password": "1234" }, // This specifies a hidden client. @@ -246,12 +244,10 @@ // The user id is the content of the // file /usr/local/share/kea/kea-creds/hiddenu. "user-file": "hiddenu", - "user": "", // The password is the content of the // file /usr/local/share/kea/kea-creds/hiddenp. - "password-file": "hiddenp", - "password": "" + "password-file": "hiddenp" }, // This specifies a hidden client using a @@ -260,10 +256,7 @@ // The secret is the content of the file // /usr/local/share/kea/kea-creds/hiddens which must be in // the : format. - "password-file": "hiddens", - "user-file": "", - "user": "", - "password": "" + "password-file": "hiddens" } ] } diff --git a/doc/examples/kea6/all-keys-netconf.json b/doc/examples/kea6/all-keys-netconf.json index ccb8ccde0a..e070989d04 100644 --- a/doc/examples/kea6/all-keys-netconf.json +++ b/doc/examples/kea6/all-keys-netconf.json @@ -187,9 +187,7 @@ // If password is not specified an empty // password is used. - "password": "1234", - "password-file": "", - "user-file": "" + "password": "1234" }, // This specifies a hidden client. @@ -197,12 +195,10 @@ // The user id is the content of the // file /usr/local/share/kea/kea-creds/hiddenu. "user-file": "hiddenu", - "user": "", // The password is the content of the // file /usr/local/share/kea/kea-creds/hiddenp. - "password-file": "hiddenp", - "password": "" + "password-file": "hiddenp" }, // This specifies a hidden client using a @@ -211,10 +207,7 @@ // The secret is the content of the file // /usr/local/share/kea/kea-creds/hiddens which must be in // the : format. - "password-file": "hiddens", - "user-file": "", - "user": "", - "password": "" + "password-file": "hiddens" } ] } diff --git a/src/lib/yang/tests/config_unittests.cc b/src/lib/yang/tests/config_unittests.cc index 4aa0ccf2f2..7a264b273e 100644 --- a/src/lib/yang/tests/config_unittests.cc +++ b/src/lib/yang/tests/config_unittests.cc @@ -280,14 +280,14 @@ TEST_F(ConfigTestKeaV4, examples4) { "backends.json", "classify.json", "classify2.json", - //"comments.json", + "comments.json", "config-backend.json", "dhcpv4-over-dhcpv6.json", "global-reservations.json", "ha-load-balancing-server1-mt-with-tls.json", "ha-load-balancing-server2-mt.json", "hooks.json", - //"hooks-radius.json", + "hooks-radius.json", "leases-expiration.json", "multiple-options.json", "mysql-reservations.json", @@ -320,7 +320,7 @@ TEST_F(ConfigTestKeaV6, examples6) { "backends.json", "classify.json", "classify2.json", - //"comments.json", + "comments.json", "config-backend.json", "dhcpv4-over-dhcpv6.json", "duid.json", diff --git a/src/lib/yang/translator_control_socket.cc b/src/lib/yang/translator_control_socket.cc index b997ae7f47..b208f94b7b 100644 --- a/src/lib/yang/translator_control_socket.cc +++ b/src/lib/yang/translator_control_socket.cc @@ -89,6 +89,7 @@ TranslatorControlSocket::getControlSocketKea(DataNode const& data_node) { checkAndGetDivergingLeaf(authentication, node, "type", "auth-type"); checkAndGetLeaf(authentication, node, "realm"); checkAndGetLeaf(authentication, node, "directory"); + checkAndGetAndJsonifyLeaf(authentication, node, "user-context"); ConstElementPtr clients = getControlSocketAuthenticationClients(node); if (clients) { authentication->set("clients", clients); @@ -132,6 +133,8 @@ TranslatorControlSocket::getControlSocketAuthenticationClient(DataNode const& da getMandatoryLeaf(result, data_node, "password"); getMandatoryLeaf(result, data_node, "user-file"); getMandatoryLeaf(result, data_node, "password-file"); + checkAndGetAndJsonifyLeaf(result, data_node, "user-context"); + return (result->empty() ? ElementPtr() : result); } @@ -235,6 +238,7 @@ TranslatorControlSocket::setControlSocketKea(string const& xpath, setMandatoryDivergingLeaf(authentication, xpath +"/authentication" , "type", "auth-type", LeafBaseType::String); checkAndSetLeaf(authentication, xpath + "/authentication", "realm", LeafBaseType::String); checkAndSetLeaf(authentication, xpath + "/authentication", "directory", LeafBaseType::String); + checkAndSetUserContext(authentication, xpath + "/authentication"); ConstElementPtr clients = authentication->get("clients"); setControlSocketAuthenticationClients(xpath + "/authentication/clients", clients); } @@ -285,8 +289,9 @@ TranslatorControlSocket::setControlSocketAuthenticationClients(string const& xpa void TranslatorControlSocket::setControlSocketAuthenticationClient(string const& xpath, - ConstElementPtr /* elem */) { + ConstElementPtr elem) { setItem(xpath, ElementPtr(), LeafBaseType::Unknown); + checkAndSetUserContext(elem, xpath); } void diff --git a/src/share/yang/modules/hashes/kea-types@2025-06-25.hash b/src/share/yang/modules/hashes/kea-types@2025-06-25.hash index d5437bc1be..c708553205 100644 --- a/src/share/yang/modules/hashes/kea-types@2025-06-25.hash +++ b/src/share/yang/modules/hashes/kea-types@2025-06-25.hash @@ -1 +1 @@ -160eb58d10c1c29ab40763f69b9d905644ee767badfdceee6bdd730e9a6071f6 +b5f9e40815ea19641d64eefaf4acd429526e5f58c7ac8154fa89cd6c0033722e diff --git a/src/share/yang/modules/kea-types@2025-06-25.yang b/src/share/yang/modules/kea-types@2025-06-25.yang index 0442731b21..639baef170 100644 --- a/src/share/yang/modules/kea-types@2025-06-25.yang +++ b/src/share/yang/modules/kea-types@2025-06-25.yang @@ -155,6 +155,10 @@ module kea-types { type string; description "HTTP password file."; } + leaf user-context { + type user-context; + description "Logger user context."; + } key "user password user-file password-file"; } } @@ -181,6 +185,10 @@ module kea-types { description "HTTP authentication directory."; } uses clients; + leaf user-context { + type user-context; + description "Logger user context."; + } } }