From 6384fb89f19c16b5028e453a57a4263d87ed11c2 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Thu, 23 Jan 2020 22:53:19 +0100 Subject: [PATCH] Fixed: Yang xpath statements containing prefixes stopped working due to namespace context updates --- CHANGELOG.md | 6 ++++++ configure | 4 ++-- configure.ac | 4 ++-- lib/src/clixon_validate.c | 11 ++++++++++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ce3d157..c16e1803 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Clixon Changelog +## 4.3.1 (Expected: January 2020) + +### Corrected Bugs +* Fixed: Yang `must` xpath statements containing prefixes stopped working due to namespace context updates + ## 4.3.0 (1 January 2020) There were several issues with multiple namespaces with augmented yangs in 4.2 that have been fixed in 4.3. Some other highlights include: several issues with XPaths including "canonical namespace context" support, a reorganization of the YANG files shipped with the release, and a wildchar in the CLICON_MODE variable. @@ -12,6 +17,7 @@ There were several issues with multiple namespaces with augmented yangs in 4.2 t * Optional yang files can be installed in a separate dir with `--with-opt-yang-installdir=DIR` (renamed from `with-std-yang-installdir`) * C-API * Changed `clicon_rpc_generate_error(msg, xerr)` to `clicon_rpc_generate_error(xerr, msg, arg)` + * If you pass NULL as arg it produces the same message as before. * Added namespace-context parameter `nsc` to `xpath_first` and `xpath_vec`, (`xpath_vec_nsc` and xpath_first_nsc` are removed). * Added clicon_handle as parameter to all `clicon_connect_` functions to get better error message diff --git a/configure b/configure index c7b411dd..81ee776e 100755 --- a/configure +++ b/configure @@ -2173,8 +2173,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu CLIXON_VERSION_MAJOR="4" CLIXON_VERSION_MINOR="3" -CLIXON_VERSION_PATCH="0" -CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}\"" +CLIXON_VERSION_PATCH="1" +CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}.PRE\"" # Check CLIgen if test "$prefix" = "NONE"; then diff --git a/configure.ac b/configure.ac index 7b5fbc70..4dcc37e6 100644 --- a/configure.ac +++ b/configure.ac @@ -44,8 +44,8 @@ AC_INIT(lib/clixon/clixon.h.in) CLIXON_VERSION_MAJOR="4" CLIXON_VERSION_MINOR="3" -CLIXON_VERSION_PATCH="0" -CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}\"" +CLIXON_VERSION_PATCH="1" +CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}.PRE\"" # Check CLIgen if test "$prefix" = "NONE"; then diff --git a/lib/src/clixon_validate.c b/lib/src/clixon_validate.c index 5d09e7bd..93af49be 100644 --- a/lib/src/clixon_validate.c +++ b/lib/src/clixon_validate.c @@ -1064,6 +1064,7 @@ xml_yang_validate_all(clicon_handle h, cxobj *x; char *namespace = NULL; cbuf *cb = NULL; + cvec *nsc = NULL; /* if not given by argument (overide) use default link and !Node has a config sub-statement and it is false */ @@ -1124,7 +1125,9 @@ xml_yang_validate_all(clicon_handle h, if (yang_keyword_get(yc) != Y_MUST) continue; xpath = yang_argument_get(yc); /* "must" has xpath argument */ - if ((nr = xpath_vec_bool(xt, NULL, "%s", xpath)) < 0) + if (xml_nsctx_yang(yc, &nsc) < 0) + goto done; + if ((nr = xpath_vec_bool(xt, nsc, "%s", xpath)) < 0) goto done; if (!nr){ ye = yang_find(yc, Y_ERROR_MESSAGE, NULL); @@ -1133,6 +1136,10 @@ xml_yang_validate_all(clicon_handle h, goto done; goto fail; } + if (nsc){ + xml_nsctx_free(nsc); + nsc = NULL; + } } /* "when" sub-node RFC 7950 Sec 7.21.5. Can only be one. */ if ((yc = yang_find(ys, Y_WHEN, NULL)) != NULL){ @@ -1165,6 +1172,8 @@ xml_yang_validate_all(clicon_handle h, ok: retval = 1; done: + if (nsc) + xml_nsctx_free(nsc); if (cb) cbuf_free(cb); return retval;