tag all netconf msg with username
This commit is contained in:
parent
5cabc11bfb
commit
ff5f93ac1e
2 changed files with 23 additions and 0 deletions
|
|
@ -134,6 +134,12 @@ process_incoming_packet(clicon_handle h,
|
||||||
if ((cbret = cbuf_new()) != NULL){
|
if ((cbret = cbuf_new()) != NULL){
|
||||||
if ((xc = xml_child_i(xret,0))!=NULL){
|
if ((xc = xml_child_i(xret,0))!=NULL){
|
||||||
xa=NULL;
|
xa=NULL;
|
||||||
|
/* Copy message-id attribute from incoming to reply.
|
||||||
|
* RFC 6241:
|
||||||
|
* If additional attributes are present in an <rpc> element, a NETCONF
|
||||||
|
* peer MUST return them unmodified in the <rpc-reply> element. This
|
||||||
|
* includes any "xmlns" attributes.
|
||||||
|
*/
|
||||||
while ((xa = xml_child_each(xrpc, xa, CX_ATTR)) != NULL){
|
while ((xa = xml_child_each(xrpc, xa, CX_ATTR)) != NULL){
|
||||||
if ((xa2 = xml_dup(xa)) ==NULL)
|
if ((xa2 = xml_dup(xa)) ==NULL)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
||||||
|
|
@ -964,12 +964,26 @@ netconf_rpc_dispatch(clicon_handle h,
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cxobj *xe;
|
cxobj *xe;
|
||||||
yang_spec *yspec = NULL;
|
yang_spec *yspec = NULL;
|
||||||
|
char *username;
|
||||||
|
cxobj *xa;
|
||||||
|
|
||||||
/* Check incoming RPC against system / netconf RPC:s */
|
/* Check incoming RPC against system / netconf RPC:s */
|
||||||
if ((yspec = clicon_netconf_yang(h)) == NULL){
|
if ((yspec = clicon_netconf_yang(h)) == NULL){
|
||||||
clicon_err(OE_YANG, ENOENT, "No netconf yang spec");
|
clicon_err(OE_YANG, ENOENT, "No netconf yang spec");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
/* Tag username on all incoming requests in case they are forwarded as internal messages
|
||||||
|
* This may be unecesary since not all are forwarded.
|
||||||
|
* It may even be wrong if something else is done with the incoming message?
|
||||||
|
*/
|
||||||
|
if ((username = clicon_username_get(h)) != NULL){
|
||||||
|
if ((xa = xml_new("username", xn, NULL)) == NULL)
|
||||||
|
goto done;
|
||||||
|
xml_type_set(xa, CX_ATTR);
|
||||||
|
if (xml_value_set(xa, username) < 0)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
xe = NULL;
|
xe = NULL;
|
||||||
while ((xe = xml_child_each(xn, xe, CX_ELMNT)) != NULL) {
|
while ((xe = xml_child_each(xn, xe, CX_ELMNT)) != NULL) {
|
||||||
if (strcmp(xml_name(xe), "get-config") == 0){
|
if (strcmp(xml_name(xe), "get-config") == 0){
|
||||||
|
|
@ -1047,5 +1061,8 @@ netconf_rpc_dispatch(clicon_handle h,
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
/* Username attribute added at top - otherwise it is returned to sender */
|
||||||
|
if ((xa = xml_find(xn, "username")) != NULL)
|
||||||
|
xml_purge(xa);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue