251251np2srv_rpc_copyconfig_cb (sr_session_ctx_t * session , const char * UNUSED (op_path ), const struct lyd_node * input ,
252252 sr_event_t UNUSED (event ), uint32_t UNUSED (request_id ), struct lyd_node * UNUSED (output ), void * UNUSED (private_data ))
253253{
254- sr_datastore_t ds = SR_DS_OPERATIONAL , sds ;
254+ sr_datastore_t ds = SR_DS_OPERATIONAL , sds = SR_DS_OPERATIONAL ;
255255 struct ly_set * nodeset ;
256256 const sr_error_info_t * err_info ;
257257 struct lyd_node * config = NULL ;
@@ -303,6 +303,12 @@ np2srv_rpc_copyconfig_cb(sr_session_ctx_t *session, const char *UNUSED(op_path),
303303 } else {
304304 assert (!strcmp (nodeset -> set .d [0 ]-> schema -> name , "url" ));
305305#ifdef NP2SRV_URL_CAPAB
306+ if (trg_url && !strcmp (trg_url , ((struct lyd_node_leaf_list * )nodeset -> set .d [0 ])-> value_str )) {
307+ rc = SR_ERR_INVAL_ARG ;
308+ sr_set_error (session , NULL , "Source and target URLs are the same." );
309+ goto cleanup ;
310+ }
311+
306312 config = op_parse_url (((struct lyd_node_leaf_list * )nodeset -> set .d [0 ])-> value_str ,
307313 LYD_OPT_CONFIG | LYD_OPT_STRICT | LYD_OPT_TRUSTED , & rc , session );
308314 if (rc ) {
@@ -318,6 +324,12 @@ np2srv_rpc_copyconfig_cb(sr_session_ctx_t *session, const char *UNUSED(op_path),
318324 }
319325 ly_set_free (nodeset );
320326
327+ if (ds == sds ) {
328+ rc = SR_ERR_INVAL_ARG ;
329+ sr_set_error (session , NULL , "Source and target datastores are the same." );
330+ goto cleanup ;
331+ }
332+
321333 /* NACM checks */
322334 if (!config && !run_to_start ) {
323335 /* get source datastore data and filter them */
@@ -452,6 +464,7 @@ np2srv_rpc_un_lock_cb(sr_session_ctx_t *session, const char *UNUSED(op_path), co
452464{
453465 sr_datastore_t ds = 0 ;
454466 struct ly_set * nodeset ;
467+ const sr_error_info_t * err_info ;
455468 int rc = SR_ERR_OK ;
456469
457470 /* get know which datastore is being affected */
@@ -476,6 +489,8 @@ np2srv_rpc_un_lock_cb(sr_session_ctx_t *session, const char *UNUSED(op_path), co
476489 rc = sr_unlock (session , NULL );
477490 }
478491 if (rc != SR_ERR_OK ) {
492+ sr_get_error (session , & err_info );
493+ sr_set_error (session , err_info -> err [0 ].xpath , err_info -> err [0 ].message );
479494 goto cleanup ;
480495 }
481496
@@ -709,6 +724,9 @@ np2srv_rpc_subscribe_cb(sr_session_ctx_t *session, const char *UNUSED(op_path),
709724 }
710725 ly_set_free (nodeset );
711726
727+ /* set ongoing notifications flag */
728+ nc_session_set_notif_status (ncs , 1 );
729+
712730 /* sysrepo API */
713731 if (!strcmp (stream , "NETCONF" )) {
714732 /* subscribe to all modules with notifications */
@@ -747,9 +765,6 @@ np2srv_rpc_subscribe_cb(sr_session_ctx_t *session, const char *UNUSED(op_path),
747765 goto cleanup ;
748766 }
749767
750- /* set ongoing notifications flag */
751- nc_session_set_notif_status (ncs , 1 );
752-
753768 /* success */
754769
755770cleanup :
@@ -758,5 +773,8 @@ np2srv_rpc_subscribe_cb(sr_session_ctx_t *session, const char *UNUSED(op_path),
758773 }
759774 free (filters );
760775 free (xp );
776+ if (ncs && rc ) {
777+ nc_session_set_notif_status (ncs , 0 );
778+ }
761779 return rc ;
762780}
0 commit comments