Cleanup master for 4.9.0.PRE

This commit is contained in:
Olof hagsand 2020-10-19 20:06:20 +02:00
parent 6fdc42a42b
commit 1614bcd19c
10 changed files with 51 additions and 43 deletions

View file

@ -1596,7 +1596,7 @@ from_client_msg(clicon_handle h,
enum nacm_credentials_t creds;
char *rpcname;
char *rpcprefix;
char *namespace;
char *namespace = NULL;
clicon_debug(1, "%s", __FUNCTION__);
yspec = clicon_dbspec_yang(h);
@ -1636,16 +1636,17 @@ from_client_msg(clicon_handle h,
}
rpcname = xml_name(x);
rpcprefix = xml_prefix(x);
if (0) { /* XXX notyet (4.8) restconf seems not to produce right namespace */
if (xml2ns(x, rpcprefix, &namespace) < 0)
/* Note that this validation is also made in xml_yang_validate_rpc, but not for hello
*/
if (xml2ns(x, rpcprefix, &namespace) < 0)
goto done;
/* Only accept resolved NETCONF base namespace */
if (namespace == NULL || strcmp(namespace, NETCONF_BASE_NAMESPACE) != 0){
if (netconf_unknown_namespace(cbret, "protocol", rpcprefix, "No appropriate namespace associated with prefix") < 0)
goto done;
/* Only accept resolved NETCONF base namespace */
if (namespace == NULL || strcmp(namespace, NETCONF_BASE_NAMESPACE) != 0){
if (netconf_unknown_namespace(cbret, "protocol", rpcprefix, "No appropriate namespace associated with prefix")< 0)
goto done;
goto reply;
}
goto reply;
}
if (strcmp(rpcname, "rpc") == 0){
; /* continue below */
}

View file

@ -477,16 +477,6 @@ from_validate_common(clicon_handle h,
/* Clear flags xpath for get */
xml_apply0(td->td_target, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset,
(void*)(XML_FLAG_MARK|XML_FLAG_CHANGE));
/* Validate the target state. It is not completely clear this should be done
* here. It is being made in generic_validate below.
* But xml_diff requires some basic validation, at least check that yang-specs
* have been assigned
*/
if ((ret = xml_yang_validate_all_top(h, td->td_target, xret)) < 0)
goto done;
if (ret == 0)
goto fail;
/* 2. Parse xml trees
* This is the state we are going from */
if (xmldb_get0(h, "running", YB_MODULE, NULL, "/", 0, &td->td_src, NULL) < 0)

View file

@ -756,7 +756,6 @@ api_operations_post(clicon_handle h,
cxobj *xbot = NULL;
yang_stmt *y = NULL;
cxobj *xoutput = NULL;
cxobj *xa;
cxobj *xe;
char *username;
cbuf *cbret = NULL;
@ -822,17 +821,18 @@ api_operations_post(clicon_handle h,
/* 3. Build xml tree with user and rpc:
* <rpc username="foo"><myfn xmlns="uri"/>
*/
if ((xtop = xml_new("rpc", NULL, CX_ELMNT)) == NULL)
if ((username = clicon_username_get(h)) != NULL){
if (clixon_xml_parse_va(YB_NONE, NULL, &xtop, NULL, "<rpc xmlns=\"%s\" username=\"%s\"/>",
NETCONF_BASE_NAMESPACE, username) < 0)
goto done;
}
else
if (clixon_xml_parse_va(YB_NONE, NULL, &xtop, NULL, "<rpc xmlns=\"%s\"/>",
NETCONF_BASE_NAMESPACE) < 0)
goto done;
if (xml_rootchild(xtop, 0, &xtop) < 0)
goto done;
xbot = xtop;
/* Here xtop is: <rpc/> */
if ((username = clicon_username_get(h)) != NULL){
if ((xa = xml_new("username", xtop, CX_ATTR)) == NULL)
goto done;
if (xml_value_set(xa, username) < 0)
goto done;
/* Here xtop is: <rpc username="foo"/> */
}
if ((ret = api_path2xml(oppath, yspec, xtop, YC_SCHEMANODE, 1, &xbot, &y, &xerr)) < 0)
goto done;
if (ret == 0){ /* validation failed */