Netconf operation attribute namespace check is enforced
This commit is contained in:
parent
2d9d204f69
commit
c97346921b
19 changed files with 86 additions and 73 deletions
|
|
@ -1377,46 +1377,46 @@ backend_rpc_init(clicon_handle h)
|
|||
|
||||
/* In backend_client.? RFC 6241 */
|
||||
if (rpc_callback_register(h, from_client_get_config, NULL,
|
||||
"urn:ietf:params:xml:ns:netconf:base:1.0", "get-config") < 0)
|
||||
NETCONF_BASE_NAMESPACE, "get-config") < 0)
|
||||
goto done;
|
||||
if (rpc_callback_register(h, from_client_edit_config, NULL,
|
||||
"urn:ietf:params:xml:ns:netconf:base:1.0", "edit-config") < 0)
|
||||
NETCONF_BASE_NAMESPACE, "edit-config") < 0)
|
||||
goto done;
|
||||
if (rpc_callback_register(h, from_client_copy_config, NULL,
|
||||
"urn:ietf:params:xml:ns:netconf:base:1.0", "copy-config") < 0)
|
||||
NETCONF_BASE_NAMESPACE, "copy-config") < 0)
|
||||
goto done;
|
||||
if (rpc_callback_register(h, from_client_delete_config, NULL,
|
||||
"urn:ietf:params:xml:ns:netconf:base:1.0", "delete-config") < 0)
|
||||
NETCONF_BASE_NAMESPACE, "delete-config") < 0)
|
||||
goto done;
|
||||
if (rpc_callback_register(h, from_client_lock, NULL,
|
||||
"urn:ietf:params:xml:ns:netconf:base:1.0", "lock") < 0)
|
||||
NETCONF_BASE_NAMESPACE, "lock") < 0)
|
||||
goto done;
|
||||
if (rpc_callback_register(h, from_client_unlock, NULL,
|
||||
"urn:ietf:params:xml:ns:netconf:base:1.0", "unlock") < 0)
|
||||
NETCONF_BASE_NAMESPACE, "unlock") < 0)
|
||||
goto done;
|
||||
if (rpc_callback_register(h, from_client_get, NULL,
|
||||
"urn:ietf:params:xml:ns:netconf:base:1.0", "get") < 0)
|
||||
NETCONF_BASE_NAMESPACE, "get") < 0)
|
||||
goto done;
|
||||
if (rpc_callback_register(h, from_client_close_session, NULL,
|
||||
"urn:ietf:params:xml:ns:netconf:base:1.0", "close-session") < 0)
|
||||
NETCONF_BASE_NAMESPACE, "close-session") < 0)
|
||||
goto done;
|
||||
if (rpc_callback_register(h, from_client_kill_session, NULL,
|
||||
"urn:ietf:params:xml:ns:netconf:base:1.0", "kill-session") < 0)
|
||||
NETCONF_BASE_NAMESPACE, "kill-session") < 0)
|
||||
goto done;
|
||||
/* In backend_commit.? */
|
||||
if (rpc_callback_register(h, from_client_commit, NULL,
|
||||
"urn:ietf:params:xml:ns:netconf:base:1.0", "commit") < 0)
|
||||
NETCONF_BASE_NAMESPACE, "commit") < 0)
|
||||
goto done;
|
||||
if (rpc_callback_register(h, from_client_discard_changes, NULL,
|
||||
"urn:ietf:params:xml:ns:netconf:base:1.0", "discard-changes") < 0)
|
||||
NETCONF_BASE_NAMESPACE, "discard-changes") < 0)
|
||||
goto done;
|
||||
/* if-feature confirmed-commit */
|
||||
if (rpc_callback_register(h, from_client_cancel_commit, NULL,
|
||||
"urn:ietf:params:xml:ns:netconf:base:1.0", "cancel-commit") < 0)
|
||||
NETCONF_BASE_NAMESPACE, "cancel-commit") < 0)
|
||||
goto done;
|
||||
/* if-feature validate */
|
||||
if (rpc_callback_register(h, from_client_validate, NULL,
|
||||
"urn:ietf:params:xml:ns:netconf:base:1.0", "validate") < 0)
|
||||
NETCONF_BASE_NAMESPACE, "validate") < 0)
|
||||
goto done;
|
||||
|
||||
/* In backend_client.? RPC from RFC 5277 */
|
||||
|
|
|
|||
|
|
@ -236,19 +236,15 @@ cli_dbxml(clicon_handle h,
|
|||
enum operation_type op)
|
||||
{
|
||||
int retval = -1;
|
||||
// char *str = NULL;
|
||||
char *api_path_fmt; /* xml key format */
|
||||
char *api_path_fmt; /* xml key format */
|
||||
char *api_path = NULL; /* xml key */
|
||||
// cg_var *cval;
|
||||
// int len;
|
||||
cg_var *arg;
|
||||
cbuf *cb = NULL;
|
||||
yang_stmt *yspec;
|
||||
cxobj *xbot = NULL; /* xpath, NULL if datastore */
|
||||
yang_stmt *y = NULL; /* yang spec of xpath */
|
||||
cxobj *xtop = NULL; /* xpath root */
|
||||
cxobj *xa; /* attribute */
|
||||
// cxobj *xb; /* body */
|
||||
cxobj *xbot = NULL; /* xpath, NULL if datastore */
|
||||
yang_stmt *y = NULL; /* yang spec of xpath */
|
||||
cxobj *xtop = NULL; /* xpath root */
|
||||
cxobj *xa; /* attribute */
|
||||
|
||||
if (cvec_len(argv) != 1){
|
||||
clicon_err(OE_PLUGIN, 0, "Requires one element to be xml key format string");
|
||||
|
|
@ -271,6 +267,7 @@ cli_dbxml(clicon_handle h,
|
|||
if ((xa = xml_new("operation", xbot, NULL)) == NULL)
|
||||
goto done;
|
||||
xml_type_set(xa, CX_ATTR);
|
||||
xml_prefix_set(xa, NETCONF_BASE_PREFIX);
|
||||
if (xml_value_set(xa, xml_operation2str(op)) < 0)
|
||||
goto done;
|
||||
if (yang_keyword_get(y) != Y_LIST && yang_keyword_get(y) != Y_LEAF_LIST){
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ netconf_create_hello(clicon_handle h,
|
|||
if ((ietf_yang_library_revision = yang_modules_revision(h)) == NULL)
|
||||
goto done;
|
||||
add_preamble(cb);
|
||||
cprintf(cb, "<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">");
|
||||
cprintf(cb, "<hello xmlns=\"%s\">", NETCONF_BASE_NAMESPACE);
|
||||
cprintf(cb, "<capabilities>");
|
||||
cprintf(cb, "<capability>urn:ietf:params:netconf:base:1.0</capability>");
|
||||
if (xml_chardata_encode(&encstr, "urn:ietf:params:netconf:capability:yang-library:1.0?revision=%s&module-set-id=%s",
|
||||
|
|
|
|||
|
|
@ -579,7 +579,7 @@ restconf_insert_attributes(cxobj *xdata,
|
|||
if (xml_prefix_set(xa, "xmlns") < 0)
|
||||
goto done;
|
||||
xml_type_set(xa, CX_ATTR);
|
||||
if (xml_value_set(xa, "urn:ietf:params:xml:ns:yang:1") < 0)
|
||||
if (xml_value_set(xa, YANG_XML_NAMESPACE) < 0)
|
||||
goto done;
|
||||
/* Then add insert attribute */
|
||||
if ((xa = xml_new("insert", xdata, NULL)) == NULL)
|
||||
|
|
|
|||
|
|
@ -290,8 +290,8 @@ api_data_put(clicon_handle h,
|
|||
char *dname;
|
||||
int nullspec = 0;
|
||||
|
||||
clicon_debug(1, "%s api_path:\"%s\" data:\"%s\"",
|
||||
__FUNCTION__, api_path0, data);
|
||||
clicon_debug(1, "%s api_path:\"%s\"", __FUNCTION__, api_path0);
|
||||
clicon_debug(1, "%s data:\"%s\"", __FUNCTION__, data);
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||
clicon_err(OE_FATAL, 0, "No DB_SPEC");
|
||||
goto done;
|
||||
|
|
@ -415,6 +415,7 @@ api_data_put(clicon_handle h,
|
|||
if ((xa = xml_new("operation", xdata, NULL)) == NULL)
|
||||
goto done;
|
||||
xml_type_set(xa, CX_ATTR);
|
||||
xml_prefix_set(xa, NETCONF_BASE_PREFIX);
|
||||
op = OP_CREATE;
|
||||
if (xml_value_set(xa, xml_operation2str(op)) < 0)
|
||||
goto done;
|
||||
|
|
@ -542,7 +543,10 @@ api_data_put(clicon_handle h,
|
|||
*/
|
||||
username = clicon_username_get(h);
|
||||
again:
|
||||
cprintf(cbx, "<rpc username=\"%s\">", username?username:"");
|
||||
cprintf(cbx, "<rpc username=\"%s\" xmlns:%s=\"%s\">",
|
||||
username?username:"",
|
||||
NETCONF_BASE_PREFIX,
|
||||
NETCONF_BASE_NAMESPACE); /* bind nc to netconf namespace */
|
||||
cprintf(cbx, "<edit-config><target><candidate /></target>");
|
||||
cprintf(cbx, "<default-operation>none</default-operation>");
|
||||
if (clicon_xml2cbuf(cbx, xtop, 0, 0) < 0)
|
||||
|
|
@ -720,6 +724,7 @@ api_data_delete(clicon_handle h,
|
|||
if ((xa = xml_new("operation", xbot, NULL)) == NULL)
|
||||
goto done;
|
||||
xml_type_set(xa, CX_ATTR);
|
||||
xml_prefix_set(xa, NETCONF_BASE_PREFIX);
|
||||
if (xml_value_set(xa, xml_operation2str(op)) < 0)
|
||||
goto done;
|
||||
if ((cbx = cbuf_new()) == NULL)
|
||||
|
|
@ -727,7 +732,10 @@ api_data_delete(clicon_handle h,
|
|||
/* For internal XML protocol: add username attribute for access control
|
||||
*/
|
||||
username = clicon_username_get(h);
|
||||
cprintf(cbx, "<rpc username=\"%s\">", username?username:"");
|
||||
cprintf(cbx, "<rpc username=\"%s\" xmlns:%s=\"%s\">",
|
||||
username?username:"",
|
||||
NETCONF_BASE_PREFIX,
|
||||
NETCONF_BASE_NAMESPACE); /* bind nc to netconf namespace */
|
||||
cprintf(cbx, "<edit-config><target><candidate /></target>");
|
||||
cprintf(cbx, "<default-operation>none</default-operation>");
|
||||
if (clicon_xml2cbuf(cbx, xtop, 0, 0) < 0)
|
||||
|
|
|
|||
|
|
@ -259,6 +259,7 @@ api_data_post(clicon_handle h,
|
|||
if ((xa = xml_new("operation", xdata, NULL)) == NULL)
|
||||
goto done;
|
||||
xml_type_set(xa, CX_ATTR);
|
||||
xml_prefix_set(xa, NETCONF_BASE_PREFIX);
|
||||
if (xml_value_set(xa, xml_operation2str(op)) < 0)
|
||||
goto done;
|
||||
/* Replace xbot with x, ie bottom of api-path with data */
|
||||
|
|
@ -304,7 +305,10 @@ api_data_post(clicon_handle h,
|
|||
/* For internal XML protocol: add username attribute for access control
|
||||
*/
|
||||
username = clicon_username_get(h);
|
||||
cprintf(cbx, "<rpc username=\"%s\">", username?username:"");
|
||||
cprintf(cbx, "<rpc username=\"%s\" xmlns:%s=\"%s\">",
|
||||
username?username:"",
|
||||
NETCONF_BASE_PREFIX,
|
||||
NETCONF_BASE_NAMESPACE); /* bind nc to netconf namespace */
|
||||
cprintf(cbx, "<edit-config><target><candidate /></target>");
|
||||
cprintf(cbx, "<default-operation>none</default-operation>");
|
||||
if (clicon_xml2cbuf(cbx, xtop, 0, 0) < 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue