@@ -303,6 +303,14 @@ nc_server_config_add_ssh_user_pubkey(const struct ly_ctx *ctx, const char *endpt
303303 goto cleanup ;
304304 }
305305
306+ /* delete use system auth if present */
307+ ret = nc_server_config_check_delete (config , "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/"
308+ "ssh-server-parameters/client-authentication/users/user[name='%s']/public-keys/"
309+ "libnetconf2-netconf-server:use-system-keys" , endpt_name , user_name );
310+ if (ret ) {
311+ goto cleanup ;
312+ }
313+
306314cleanup :
307315 free (path );
308316 return ret ;
@@ -337,6 +345,15 @@ nc_server_config_add_ch_ssh_user_pubkey(const struct ly_ctx *ctx, const char *cl
337345 goto cleanup ;
338346 }
339347
348+ /* delete use system auth if present */
349+ ret = nc_server_config_check_delete (config , "/ietf-netconf-server:netconf-server/call-home/"
350+ "netconf-client[name='%s']/endpoints/endpoint[name='%s']/ssh/"
351+ "ssh-server-parameters/client-authentication/users/user[name='%s']/public-keys/"
352+ "libnetconf2-netconf-server:use-system-keys" , client_name , endpt_name , user_name );
353+ if (ret ) {
354+ goto cleanup ;
355+ }
356+
340357cleanup :
341358 free (path );
342359 return ret ;
@@ -378,6 +395,106 @@ nc_server_config_del_ch_ssh_user_pubkey(const char *client_name, const char *end
378395 }
379396}
380397
398+ API int
399+ nc_server_config_add_ssh_user_authkey (const struct ly_ctx * ctx , const char * endpt_name ,
400+ const char * user_name , struct lyd_node * * config )
401+ {
402+ int ret = 0 ;
403+ char * path = NULL ;
404+
405+ NC_CHECK_ARG_RET (NULL , ctx , endpt_name , user_name , config , 1 );
406+
407+ ret = asprintf (& path , "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/ssh-server-parameters/"
408+ "client-authentication/users/user[name='%s']/public-keys" , endpt_name , user_name );
409+ NC_CHECK_ERRMEM_GOTO (ret == -1 , path = NULL ; ret = 1 , cleanup );
410+
411+ ret = nc_server_config_append (ctx , path , "libnetconf2-netconf-server:use-system-keys" , NULL , config );
412+ if (ret ) {
413+ goto cleanup ;
414+ }
415+
416+ /* delete inline definition nodes if present */
417+ ret = nc_server_config_check_delete (config , "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/"
418+ "ssh-server-parameters/client-authentication/users/user[name='%s']/public-keys/inline-definition" ,
419+ endpt_name , user_name );
420+ if (ret ) {
421+ goto cleanup ;
422+ }
423+
424+ /* delete truststore reference if present */
425+ ret = nc_server_config_check_delete (config , "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/"
426+ "ssh-server-parameters/client-authentication/users/user[name='%s']/public-keys/truststore-reference" ,
427+ endpt_name , user_name );
428+ if (ret ) {
429+ goto cleanup ;
430+ }
431+
432+ cleanup :
433+ free (path );
434+ return ret ;
435+ }
436+
437+ API int
438+ nc_server_config_add_ch_ssh_user_authkey (const struct ly_ctx * ctx , const char * client_name ,
439+ const char * endpt_name , const char * user_name , struct lyd_node * * config )
440+ {
441+ int ret = 0 ;
442+ char * path = NULL ;
443+
444+ NC_CHECK_ARG_RET (NULL , ctx , client_name , endpt_name , user_name , config , 1 );
445+
446+ ret = asprintf (& path , "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='%s']/endpoints/"
447+ "endpoint[name='%s']/ssh/ssh-server-parameters/client-authentication/users"
448+ "/user[name='%s']/public-keys" , client_name , endpt_name , user_name );
449+ NC_CHECK_ERRMEM_GOTO (ret == -1 , path = NULL ; ret = 1 , cleanup );
450+
451+ ret = nc_server_config_append (ctx , path , "libnetconf2-netconf-server:use-system-keys" , NULL , config );
452+ if (ret ) {
453+ goto cleanup ;
454+ }
455+
456+ /* delete inline definition nodes if present */
457+ ret = nc_server_config_check_delete (config , "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='%s']/"
458+ "endpoints/endpoint[name='%s']/ssh/ssh-server-parameters/client-authentication/users/user[name='%s']/"
459+ "public-keys/inline-definition" , client_name , endpt_name , user_name );
460+ if (ret ) {
461+ goto cleanup ;
462+ }
463+
464+ /* delete truststore reference if present */
465+ ret = nc_server_config_check_delete (config , "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='%s']/"
466+ "endpoints/endpoint[name='%s']/ssh/ssh-server-parameters/client-authentication/users/user[name='%s']/"
467+ "public-keys/truststore-reference" , client_name , endpt_name , user_name );
468+ if (ret ) {
469+ goto cleanup ;
470+ }
471+
472+ cleanup :
473+ free (path );
474+ return ret ;
475+ }
476+
477+ API int
478+ nc_server_config_del_ssh_user_authkey (const char * endpt_name , const char * user_name , struct lyd_node * * config )
479+ {
480+ NC_CHECK_ARG_RET (NULL , endpt_name , user_name , config , 1 );
481+
482+ return nc_server_config_delete (config , "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/"
483+ "ssh-server-parameters/client-authentication/users/user[name='%s']/"
484+ "public-keys/libnetconf2-netconf-server:use-system-keys" , endpt_name , user_name );
485+ }
486+
487+ API int
488+ nc_server_config_ch_del_ssh_user_authkey (const char * client_name , const char * endpt_name ,
489+ const char * user_name , struct lyd_node * * config )
490+ {
491+ NC_CHECK_ARG_RET (NULL , client_name , endpt_name , user_name , config , 1 );
492+
493+ return nc_server_config_delete (config , "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='%s']/endpoints/"
494+ "endpoint[name='%s']/ssh/ssh-server-parameters/client-authentication/users/user[name='%s']/"
495+ "public-keys/libnetconf2-netconf-server:use-system-keys" , endpt_name , user_name );
496+ }
497+
381498static int
382499_nc_server_config_add_ssh_user_password (const struct ly_ctx * ctx , const char * tree_path ,
383500 const char * password , struct lyd_node * * config )
@@ -615,6 +732,14 @@ nc_server_config_add_ssh_truststore_ref(const struct ly_ctx *ctx, const char *en
615732 goto cleanup ;
616733 }
617734
735+ /* delete use system auth if present */
736+ ret = nc_server_config_check_delete (config , "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/"
737+ "ssh-server-parameters/client-authentication/users/user[name='%s']/public-keys/"
738+ "libnetconf2-netconf-server:use-system-keys" , endpt_name , user_name );
739+ if (ret ) {
740+ goto cleanup ;
741+ }
742+
618743cleanup :
619744 return ret ;
620745}
@@ -642,6 +767,15 @@ nc_server_config_add_ch_ssh_truststore_ref(const struct ly_ctx *ctx, const char
642767 goto cleanup ;
643768 }
644769
770+ /* delete use system auth if present */
771+ ret = nc_server_config_check_delete (config , "/ietf-netconf-server:netconf-server/call-home/"
772+ "netconf-client[name='%s']/endpoints/endpoint[name='%s']/ssh/"
773+ "ssh-server-parameters/client-authentication/users/user[name='%s']/public-keys/"
774+ "libnetconf2-netconf-server:use-system-keys" , client_name , endpt_name , user_name );
775+ if (ret ) {
776+ goto cleanup ;
777+ }
778+
645779cleanup :
646780 return ret ;
647781}
0 commit comments